Replace underscores in HTML output

This commit is contained in:
Cohee
2024-08-19 01:26:27 +03:00
parent f8dbe262c7
commit 138d6877f7

View File

@ -7,11 +7,11 @@ export const markdownUnderscoreExt = () => {
} }
return [{ return [{
type: 'lang', type: 'output',
regex: /(`{3,})\s*\n[\s\S]*?\n\1(?:\n|$)|(`{1,2}).*?\2|(\n`\n[\s\S]*?\n`\n)|(?<!\S)_(?!_)([^_\n]+?)(?<!_)_(?!\w)/g, regex: new RegExp('(<code>[\\s\\S]*?<\\/code>)|(?<!\\S)_(?!_)([^_\\n]+?)(?<!_)_(?!\\w)', 'g'),
replace: function(match, tripleBackticks, singleOrDoubleBackticks, singleBackticksWithLineBreaks, italicContent) { replace: function(match, codeContent, italicContent) {
if (singleOrDoubleBackticks || tripleBackticks || singleBackticksWithLineBreaks) { if (codeContent) {
// If it's any type of backticks, return unchanged // If it's inside <code> tags, return unchanged
return match; return match;
} else if (italicContent) { } else if (italicContent) {
// If it's an italic group, apply the replacement // If it's an italic group, apply the replacement