fix(markdown): require double-tilde strikethrough delimiters

This commit is contained in:
Armin Ronacher
2026-04-16 12:32:51 +02:00
parent 624a7f794f
commit db5274b48c
3 changed files with 65 additions and 2 deletions

View File

@@ -1448,9 +1448,23 @@
}
// Configure marked with syntax highlighting and HTML escaping for text
const strictStrikethroughRegex = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
marked.use({
breaks: true,
gfm: true,
tokenizer: {
del(src) {
const match = strictStrikethroughRegex.exec(src);
if (!match) return undefined;
return {
type: 'del',
raw: match[0],
text: match[2],
tokens: this.lexer.inlineTokens(match[2])
};
}
},
renderer: {
// Code blocks: syntax highlight, no HTML escaping
code(token) {