Fix for unmatched single backticks
This commit is contained in:
parent
c0c09f9a5d
commit
e137c5d154
|
@ -8,15 +8,17 @@ export const markdownUnderscoreExt = () => {
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
type: 'lang',
|
type: 'lang',
|
||||||
regex: new RegExp('(`{1,3}).*?\\1|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'gs'),
|
regex: new RegExp('(`{3})[\\s\\S]*?\\1|(`{1,2}).*?\\2|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'),
|
||||||
replace: function(match, codeBlock, italicContent) {
|
replace: function(match, tripleBackticks, singleOrDoubleBackticks, italicContent) {
|
||||||
if (codeBlock) {
|
if (tripleBackticks || singleOrDoubleBackticks) {
|
||||||
// If it's a code block, return it unchanged
|
// If it's any kind of code block, return it unchanged
|
||||||
return match;
|
return match;
|
||||||
} else {
|
} else if (italicContent) {
|
||||||
// If it's an italic group, apply the replacement
|
// If it's an italic group, apply the replacement
|
||||||
return `<em>${italicContent}</em>`;
|
return '<em>' + italicContent + '</em>';
|
||||||
}
|
}
|
||||||
|
// If neither condition is met, return the original match
|
||||||
|
return match;
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue