From dc7b8968e678f51ea00e2be3fe8c717d114691a3 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Wed, 23 Sep 2026 14:24:43 +0800 Subject: [PATCH 1/4] Disable `singleDollarTextMath` in `mdast-util-math` (#20140) --- changelog_unreleased/markdown/20140.md | 13 +++++++++++ src/language-markdown/parse/parse-markdown.js | 2 +- .../math/__snapshots__/format.test.js.snap | 23 ++++++++++++++++++- tests/format/markdown/math/issue-20135.md | 5 ++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 changelog_unreleased/markdown/20140.md create mode 100644 tests/format/markdown/math/issue-20135.md diff --git a/changelog_unreleased/markdown/20140.md b/changelog_unreleased/markdown/20140.md new file mode 100644 index 000000000..7ccb73147 --- /dev/null +++ b/changelog_unreleased/markdown/20140.md @@ -0,0 +1,13 @@ +#### Fix text with `$` been incorrectly parsed as math syntax (#20140 by @fisker) + + +```md + +**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR` from `c.sh`, before anything else runs here. + + +**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR`from`c.sh`, before anything else runs here. + + +**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR` from `c.sh`, before anything else runs here. +``` diff --git a/src/language-markdown/parse/parse-markdown.js b/src/language-markdown/parse/parse-markdown.js index ba7f76a2b..32888ee21 100644 --- a/src/language-markdown/parse/parse-markdown.js +++ b/src/language-markdown/parse/parse-markdown.js @@ -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 diff --git a/tests/format/markdown/math/__snapshots__/format.test.js.snap b/tests/format/markdown/math/__snapshots__/format.test.js.snap index 291f12842..84fa7c571 100644 --- a/tests/format/markdown/math/__snapshots__/format.test.js.snap +++ b/tests/format/markdown/math/__snapshots__/format.test.js.snap @@ -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... ================================================================================ `; diff --git a/tests/format/markdown/math/issue-20135.md b/tests/format/markdown/math/issue-20135.md new file mode 100644 index 000000000..87b1a94db --- /dev/null +++ b/tests/format/markdown/math/issue-20135.md @@ -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`. From cdd17f2288b28b170a76416c72dac56e3ea5daff Mon Sep 17 00:00:00 2001 From: fisker Date: Wed, 23 Sep 2026 14:27:25 +0800 Subject: [PATCH 2/4] Release 3.9.9 --- .github/ISSUE_TEMPLATE/formatting.md | 2 +- .github/ISSUE_TEMPLATE/integration.md | 2 +- CHANGELOG.md | 18 ++++++++++ package.json | 2 +- .../versioned_docs/version-stable/browser.md | 36 +++++++++---------- .../versioned_docs/version-stable/install.md | 10 +++--- .../version-stable/sharing-configurations.md | 4 +-- 7 files changed, 46 insertions(+), 28 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index 51afd79a3..318c1fa06 100644 --- a/.github/ISSUE_TEMPLATE/formatting.md +++ b/.github/ISSUE_TEMPLATE/formatting.md @@ -26,7 +26,7 @@ Don't fill the form below manually! Let a program create a report for you: --> -**Prettier 3.9.8** +**Prettier 3.9.9** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index 7159721e9..eecc04a51 100644 --- a/.github/ISSUE_TEMPLATE/integration.md +++ b/.github/ISSUE_TEMPLATE/integration.md @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE: **Environments:** -- Prettier Version: 3.9.8 +- Prettier Version: 3.9.9 - Running Prettier via: - Runtime: - Operating System: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ee7ce72d..dce14e5f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +# 3.9.9 + +[diff](https://github.com/prettier/prettier/compare/3.9.8...3.9.9) + +#### Markdown: Fix text with `$` been incorrectly parsed as math syntax ([#20140](https://github.com/prettier/prettier/pull/20140) by [@fisker](https://github.com/fisker)) + + +```md + +**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR` from `c.sh`, before anything else runs here. + + +**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR`from`c.sh`, before anything else runs here. + + +**Uses $FOO** from `a.sh` and `b.sh`, plus `$BAR` from `c.sh`, before anything else runs here. +``` + # 3.9.8 [diff](https://github.com/prettier/prettier/compare/3.9.7...3.9.8) diff --git a/package.json b/package.json index eaf300ed1..fd261fad1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prettier", - "version": "3.10.0-dev", + "version": "3.9.9", "description": "Prettier is an opinionated code formatter", "bin": "./bin/prettier.cjs", "repository": "prettier/prettier", diff --git a/website/versioned_docs/version-stable/browser.md b/website/versioned_docs/version-stable/browser.md index 0bed0c14c..7d99f1bd2 100644 --- a/website/versioned_docs/version-stable/browser.md +++ b/website/versioned_docs/version-stable/browser.md @@ -21,7 +21,7 @@ Required options: - **[`parser`](options.md#parser) (or [`filepath`](options.md#file-path))**: One of these options has to be specified for Prettier to know which parser to use. -- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource-options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in [https://unpkg.com/browse/prettier@3.9.8/plugins](https://unpkg.com/browse/prettier@3.9.8/plugins). Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON. +- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource-options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in [https://unpkg.com/browse/prettier@3.9.9/plugins](https://unpkg.com/browse/prettier@3.9.9/plugins). Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON. You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option. @@ -32,8 +32,8 @@ See below for examples. ### Global ```html - - + +