Skip to content

Commit 95c7231

Browse files
authored
fix(html-serializer): Remove support for single tilde syntax for strike-through text (#1055)
BREAKING CHANGE: Removed support for the single tilde syntax (e.g., `~text~`) for strike-through formatting. Please update your content to use the double tilde syntax (e.g., `~~text~~`) instead.
1 parent 4537f0a commit 95c7231

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/serializers/html/html.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ This text is __*really important*__.
4343
This text is **_really important_**.
4444
This is really ***very*** important text.
4545
46-
Strikethrough uses two tildes: ~~scratch this~~`
46+
Strikethrough uses two tildes: ~~scratch this~~
47+
Strikethrough with a single tilde: ~not scratched~`
4748

4849
const MARKDOWN_INPUT_BLOCKQUOTES = `> Dorothy followed her through many of the beautiful rooms in her castle.
4950
@@ -283,7 +284,7 @@ describe('HTML Serializer', () => {
283284

284285
test('styled text syntax is preserved', () => {
285286
expect(htmlSerializer.serialize(MARKDOWN_INPUT_STYLED_TEXT)).toBe(
286-
'<p>I just love **bold text**.</p><p>I just love __bold text__.</p><p></p><p>Italicized text is the *cat&#39;s meow*.</p><p>Italicized text is the _cat&#39;s meow_.</p><p></p><p>This text is ***really important***.</p><p>This text is ___really important___.</p><p>This text is __*really important*__.</p><p>This text is **_really important_**.</p><p>This is really ***very*** important text.</p><p></p><p>Strikethrough uses two tildes: ~~scratch this~~</p>',
287+
'<p>I just love **bold text**.</p><p>I just love __bold text__.</p><p></p><p>Italicized text is the *cat&#39;s meow*.</p><p>Italicized text is the _cat&#39;s meow_.</p><p></p><p>This text is ***really important***.</p><p>This text is ___really important___.</p><p>This text is __*really important*__.</p><p>This text is **_really important_**.</p><p>This is really ***very*** important text.</p><p></p><p>Strikethrough uses two tildes: ~~scratch this~~</p><p>Strikethrough with a single tilde: ~not scratched~</p>',
287288
)
288289
})
289290

@@ -417,7 +418,7 @@ Answer: [Doist Frontend](channel://190200)`),
417418

418419
test('styled text HTML output is correct', () => {
419420
expect(htmlSerializer.serialize(MARKDOWN_INPUT_STYLED_TEXT)).toBe(
420-
"<p>I just love <strong>bold text</strong>.<br>I just love <strong>bold text</strong>.</p><p>Italicized text is the <em>cat's meow</em>.<br>Italicized text is the <em>cat's meow</em>.</p><p>This text is <em><strong>really important</strong></em>.<br>This text is <em><strong>really important</strong></em>.<br>This text is <strong><em>really important</em></strong>.<br>This text is <strong><em>really important</em></strong>.<br>This is really <em><strong>very</strong></em> important text.</p><p>Strikethrough uses two tildes: <del>scratch this</del></p>",
421+
"<p>I just love <strong>bold text</strong>.<br>I just love <strong>bold text</strong>.</p><p>Italicized text is the <em>cat's meow</em>.<br>Italicized text is the <em>cat's meow</em>.</p><p>This text is <em><strong>really important</strong></em>.<br>This text is <em><strong>really important</strong></em>.<br>This text is <strong><em>really important</em></strong>.<br>This text is <strong><em>really important</em></strong>.<br>This is really <em><strong>very</strong></em> important text.</p><p>Strikethrough uses two tildes: <del>scratch this</del><br>Strikethrough with a single tilde: ~not scratched~</p>",
421422
)
422423
})
423424

@@ -568,7 +569,8 @@ Italicized text is the _cat's meow_.</p><p>This text is ***really important***.
568569
This text is ___really important___.
569570
This text is __*really important*__.
570571
This text is **_really important_**.
571-
This is really ***very*** important text.</p><p>Strikethrough uses two tildes: ~~scratch this~~</p>`)
572+
This is really ***very*** important text.</p><p>Strikethrough uses two tildes: ~~scratch this~~
573+
Strikethrough with a single tilde: ~not scratched~</p>`)
572574
})
573575

574576
test('blockquotes HTML output is preserved', () => {

src/serializers/html/html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function createHTMLSerializer(schema: Schema): HTMLSerializerReturnType {
104104
// Configure the unified processor to use a custom plugin to add support for the strikethrough
105105
// extension from the GitHub Flavored Markdown (GFM) specification
106106
if (schema.marks.strike) {
107-
unifiedProcessor.use(remarkStrikethrough)
107+
unifiedProcessor.use(remarkStrikethrough, { singleTilde: false })
108108
}
109109

110110
// Configure the unified processor to use a custom plugin to add support for the autolink

0 commit comments

Comments
 (0)