Disable singleDollarTextMath in mdast-util-math (#20140)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-09-23 14:24:43 +08:00
1 parent f9be58fb8e
commit dc7b8968e6
4 files changed
+41 -2

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
#### Fix text with `$` been incorrectly parsed as math syntax (#20140 by @fisker)
<!-- prettier-ignore -->
```md
<!-- Input -->
**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR` from `c.sh`, before anything else runs here.
<!-- Prettier stable -->
**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR`from`c.sh`, before anything else runs here.
<!-- Prettier main -->
**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR` from `c.sh`, before anything else runs here.
```
@@ -17,7 +17,7 @@ function getMarkdownParseOptions() {
return (markdownParseOptions ??= {
extensions: [
gfmSyntax({ singleTilde: false }),
mathSyntax(),
mathSyntax({ singleDollarTextMath: false }),
wikiLinkSyntax({
// We don't need support alias, use a fake string to bypass
// https://github.com/stereobooster/braindb/blob/66d6cf74d0bad43f20924a14e382a432ff81cdfa/packages/micromark-extension-wiki-link/src/syntax.ts#L81
@@ -66,6 +66,27 @@ $$ \\textrm{p-value} = 1 - \\sum_{x \\leq a} H(x | N, r_1, m_1) $$
================================================================================
`;
exports[`issue-20135.md format 1`] = `
====================================options=====================================
parsers: ["markdown"]
printWidth: 80 (default) |
=====================================input======================================
**Uses $FOO** from \`a.sh\` and \`b.sh\`, plus \`$BAR\` from \`c.sh\`, before anything else runs here.
**Sourced-from-$DOTFILES files** - listed in \`.stow-local-ignore\`. They live only inside the repo
and are pulled in by \`.zshrc\` via \`$DOTFILES\` (which is set to \`~/.dotfiles\` in \`.zshrc\`). Key
examples: \`exports.zsh\`, \`aliases.zsh\`, \`dirs.zsh\`, \`completions/\`, \`_plugins/loader.zsh\`.
=====================================output=====================================
**Uses $FOO** from \`a.sh\` and \`b.sh\`, plus \`$BAR\` from \`c.sh\`, before anything else runs here.
**Sourced-from-$DOTFILES files** - listed in \`.stow-local-ignore\`. They live only inside the repo
and are pulled in by \`.zshrc\` via \`$DOTFILES\` (which is set to \`~/.dotfiles\` in \`.zshrc\`). Key
examples: \`exports.zsh\`, \`aliases.zsh\`, \`dirs.zsh\`, \`completions/\`, \`_plugins/loader.zsh\`.
================================================================================
`;
exports[`math-like.md format 1`] = `
====================================options=====================================
parsers: ["markdown"]
@@ -78,7 +99,7 @@ Paragraph with $14 million. But if more $dollars on the same line...
=====================================output=====================================
$10 - $20
Paragraph with $14 million. But if more $dollars on the same line...
Paragraph with $14 million. But if more $dollars on the same line...
================================================================================
`;
@@ -0,0 +1,5 @@
**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR` from `c.sh`, before anything else runs here.
**Sourced-from-$DOTFILES files** - listed in `.stow-local-ignore`. They live only inside the repo
and are pulled in by `.zshrc` via `$DOTFILES` (which is set to `~/.dotfiles` in `.zshrc`). Key
examples: `exports.zsh`, `aliases.zsh`, `dirs.zsh`, `completions/`, `_plugins/loader.zsh`.