Preserve single tildes in Markdown (#19739)

Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
Lazizbek Ergashevandfisker authored and fisker committed 2026-09-16 15:33:00 +08:00
1 parent b923138612
commit e546c510dd
5 files changed
+38 -2

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
#### Preserve single tildes in Markdown (#19739 by @lazerg)
Since 3.9.0, single-tilde spans like `H~2~O` were rewritten to double tildes, turning subscript syntax into strike-through. Only double tildes are treated that way now, matching GitHub.
<!-- prettier-ignore -->
```markdown
<!-- Input -->
H~2~O
<!-- Prettier stable -->
H~~2~~O
<!-- Prettier main -->
H~2~O
```
@@ -16,7 +16,7 @@ let markdownParseOptions;
function getMarkdownParseOptions() {
return (markdownParseOptions ??= {
extensions: [
gfmSyntax(),
gfmSyntax({ singleTilde: false }),
mathSyntax(),
wikiLinkSyntax({
// We don't need support alias, use a fake string to bypass
@@ -13,3 +13,21 @@ proseWrap: "always"
================================================================================
`;
exports[`single-tilde.md - {"proseWrap":"always"} format 1`] = `
====================================options=====================================
parsers: ["markdown"]
proseWrap: "always"
printWidth: 80 (default) |
=====================================input======================================
H~2~O
~~2~~ and ~1~ and ~~~3~~~ and ~~~~4~~~~
=====================================output=====================================
H~2~O
~~2~~ and ~1~ and ~~~3~~~ and ~~~~4~~~~
================================================================================
`;
@@ -0,0 +1,3 @@
H~2~O
~~2~~ and ~1~ and ~~~3~~~ and ~~~~4~~~~
@@ -300,7 +300,7 @@ proseWrap: "always"
~~Hi~~ Hello, ~there~ world!
=====================================output=====================================
~~Hi~~ Hello, ~~there~~ world!
~~Hi~~ Hello, ~there~ world!
================================================================================
`;