Fix for single backticks with line breaks

This commit is contained in:
Cohee 2024-08-18 14:22:31 +03:00
parent 5f3dddfe21
commit f8dbe262c7

View File

@ -8,10 +8,10 @@ export const markdownUnderscoreExt = () => {
return [{ return [{
type: 'lang', type: 'lang',
regex: /(`{3,})\s*\n[\s\S]*?\n\1(?:\n|$)|(`{1,2}).*?\2|(?<!\S)_(?!_)([^_\n]+?)(?<!_)_(?!\w)/g, regex: /(`{3,})\s*\n[\s\S]*?\n\1(?:\n|$)|(`{1,2}).*?\2|(\n`\n[\s\S]*?\n`\n)|(?<!\S)_(?!_)([^_\n]+?)(?<!_)_(?!\w)/g,
replace: function(match, tripleBackticks, singleOrDoubleBackticks, italicContent) { replace: function(match, tripleBackticks, singleOrDoubleBackticks, singleBackticksWithLineBreaks, italicContent) {
if (singleOrDoubleBackticks || tripleBackticks) { if (singleOrDoubleBackticks || tripleBackticks || singleBackticksWithLineBreaks) {
// If it's backticks, return unchanged // If it's any type of backticks, 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