Escape Non-ASCII to Markdown
The Escape Non-ASCII to Markdown extension for Visual Studio Code helps you replace non-ASCII characters in a document with markdown or HTML escape sequences. This can be especially useful for ensuring that your content renders correctly across various platforms and devices.
Features
- Easy-to-Use: Simply activate the extension and replace non-ASCII characters directly in your active document.
- Detect and Highlight Non-ASCII Characters: Easily identify lines with non-ASCII characters and get a detailed highlighting of each non-ASCII character.
- Clear Highlighted Non-ASCII Characters: Once detected, you can clear the highlighting of non-ASCII characters for a cleaner view.
- Customizable Mappings: Customize how characters are mapped using settings.
How to Use
- Install and activate the Escape Non-ASCII to Markdown extension.
- Open a document with non-ASCII characters.
- Run the command Escape Non-ASCII to MD from the command palette (
Ctrl+Shift+P
or Cmd+Shift+P
).
- The non-ASCII characters in your active document (or selected text) will be replaced according to the character mapping.
- To detect and highlight non-ASCII characters, run the command Detect Invalid Characters from the command palette. This will highlight lines containing non-ASCII characters and provide a detailed view of each one.
- If you wish to clear the highlighting of non-ASCII characters, run the command Clear Invalid Char Decorations from the command palette.
Settings
You can customize the character mapping by adjusting the extension's settings. Here's how you can do it:
The setting uses a JSON format to map non-ASCII characters to their desired markdown or HTML escape sequences.
In the above example, the left double quotation mark (“) is replaced with its HTML entity (“), and the em dash (—) is replaced with a simple hyphen (-).
Adding More Mappings
To add more mappings, you can edit the settings in VS Code:
- Go to the settings (File > Preferences > Settings or Code > Preferences > Settings).
- In the search bar, type
escape-non-ascii-to-md.characterMapping
or simply escape-non-ascii-to-md
- Edit the JSON to add or modify the existing mappings. Ensure the JSON format is valid.
Default Character Mapping
The extension comes with a default character mapping which includes a variety of commonly used non-ASCII characters. Here's a brief sample of the default mappings:
{
"‑": "-",
"–": "-",
"—": "-",
"″": """,
"“": "“",
"”": "”",
"‘": "‘",
"’": "’",
"™": "™",
"®": "®",
"©": "©",
"µ": "µ",
"·": "·",
"°": "°",
"º": "º",
"ª": "ª",
"ß": "ss",
"æ": "æ",
"œ": "œ",
"€": "€",
"£": "£",
"¥": "¥",
"¢": "¢",
"¿": "¿",
"¡": "¡",
"÷": "/",
"×": "x",
"«": "«",
"»": "»",
"§": "§",
"¶": "¶",
"¤": "¤",
"¦": "|",
"¨": "¨",
"¬": "¬",
"¯": "¯",
"¸": "¸",
"´": "´",
"¹": "1",
"²": "2",
"³": "3",
"¼": "¼",
"½": "½",
"¾": "¾",
"â": "a",
"á": "a",
"à": "a",
"ä": "a",
"ã": "a",
"ê": "e",
"é": "e",
"è": "e",
"ë": "e",
"í": "i",
"î": "i",
"ì": "i",
"ï": "i",
"ô": "o",
"ó": "o",
"ò": "o",
"ö": "o",
"õ": "o",
"ú": "u",
"û": "u",
"ù": "u",
"ü": "u"
}