mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Don't replace underscore italics inside of code blocks
This commit is contained in:
@ -8,8 +8,16 @@ export const markdownUnderscoreExt = () => {
|
|||||||
|
|
||||||
return [{
|
return [{
|
||||||
type: 'lang',
|
type: 'lang',
|
||||||
regex: new RegExp('\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'),
|
regex: new RegExp('(`{1,3}).*?\\1|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'gs'),
|
||||||
replace: '<em>$1</em>',
|
replace: function(match, codeBlock, italicContent) {
|
||||||
|
if (codeBlock) {
|
||||||
|
// If it's a code block, return it unchanged
|
||||||
|
return match;
|
||||||
|
} else {
|
||||||
|
// If it's an italic group, apply the replacement
|
||||||
|
return `<em>${italicContent}</em>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
}];
|
}];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error in Showdown-underscore extension:', e);
|
console.error('Error in Showdown-underscore extension:', e);
|
||||||
|
Reference in New Issue
Block a user