Markdown Editor: escaped dollar signs (\$, $) disappear, and two prices in one paragraph render as inline math
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
- VS Code Version: 1.136.1 (a44adf7f53e00964ab890f9f8758a334f1fc15bc, arm64)
- OS Version: macOS 26.5.2
- Does this issue occur when all extensions are disabled?: Yes (reproduced in a window started with `code --disable-extensions`)
Affects the built-in Markdown Editor (`vscode.markdown.editor`, the hybrid/WYSIWYG editor). The plain Markdown Preview renders the same file correctly.
**Steps to reproduce**
1. Create a `.md` file with these lines:
```
1. bare: only the $530 one vs "$1,027 misdirected, not $530" ($497 also)
2. backslash: only the \$530 one vs "\$1,027 misdirected, not \$530" (\$497 also)
3. numeric entity: only the $530 one vs "$1,027 misdirected, not $530" ($497 also)
4. named entity: only the $530 one vs "$1,027 misdirected, not $530" ($497 also)
5. code span: only the `$530` one vs "`$1,027` misdirected, not `$530`" (`$497` also)
```
2. Right-click the tab, Open With, Markdown Editor.
**Expected**
Lines 1-4 show the dollar signs as ordinary text. Per CommonMark, `\$`, `$`, and `$` are a literal `$`, and prose with two prices in one paragraph is not math. The Markdown Preview renders all five lines correctly.
**Actual**
- Line 1: `$530 one vs "$` and `$530" ($` are rendered as inline math (KaTeX italics), leaving `1,027 misdirected, not` and `497 also)` as text.
- Lines 2, 3, 4: the dollar signs are removed entirely; the line reads `only the 530 one vs " 1,027 misdirected, not 530" ( 497 also)` with blank space where each `$` was.
- Line 5 (code spans) is the only form that shows the sign.
**Notes from the shipped bundle**
`extensions/markdown-language-features/markdown-editor-out/editor.js` uses micromark with `micromark-extension-math` (`singleDollarTextMath` defaults to true). That tokenizer has no closing-delimiter adjacency check, unlike the preview's `@vscode/markdown-it-katex`, which refuses a closer followed by a digit or preceded by whitespace. Running the same lines through micromark + micromark-extension-math directly returns a literal `$` for lines 2-4, so the loss of the escaped sign happens in the editor's rendering layer, not the parser. Nothing in `dist/extension.js` wires `markdown.math.enabled` to this editor, so there is no setting that turns math off here.
**Suggested fixes** (any one helps)
- Honor `\$`, `$`, and `$` as literal text in the rendered view.
- Apply the same closing-delimiter adjacency rule the Markdown Preview uses for `$...$`.
- Let `markdown.math.enabled: false` disable math in this editor too.
Contributor guide
Assessment
This issue has not been assessed yet.