mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix for unmatched triple backticks
This commit is contained in:
@@ -8,16 +8,16 @@ export const markdownUnderscoreExt = () => {
|
|||||||
|
|
||||||
return [{
|
return [{
|
||||||
type: 'lang',
|
type: 'lang',
|
||||||
regex: new RegExp('(`{3})[\\s\\S]*?\\1|(`{1,2}).*?\\2|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'),
|
regex: /(`{3,})\s*\n[\s\S]*?\n\1(?:\n|$)|(`{1,2}).*?\2|(?<!\S)_(?!_)([^_\n]+?)(?<!_)_(?!\w)/g,
|
||||||
replace: function(match, tripleBackticks, singleOrDoubleBackticks, italicContent) {
|
replace: function(match, tripleBackticks, singleOrDoubleBackticks, italicContent) {
|
||||||
if (tripleBackticks || singleOrDoubleBackticks) {
|
if (singleOrDoubleBackticks || tripleBackticks) {
|
||||||
// If it's any kind of code block, return it unchanged
|
// If it's 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
|
||||||
return '<em>' + italicContent + '</em>';
|
return '<em>' + italicContent + '</em>';
|
||||||
}
|
}
|
||||||
// If neither condition is met, return the original match
|
// If none of the conditions are met, return the original match
|
||||||
return match;
|
return match;
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
Reference in New Issue
Block a user