Fix for unmatched single backticks

e137c5d1543a3238683630098504de8515aa75e2

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +8 -6Showing whitespace changes
public/scripts/showdown-underscore.js+8 -6
@@ -8,15 +8,17 @@ export const markdownUnderscoreExt = () => {
88
9 return [{9 return [{
10 type: 'lang',10 type: 'lang',
11 regex: new RegExp('(`{1,3}).*?\\1|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'gs'),11 regex: new RegExp('(`{3})[\\s\\S]*?\\1|(`{1,2}).*?\\2|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'),
12 replace: function(match, codeBlock, italicContent) {12 replace: function(match, tripleBackticks, singleOrDoubleBackticks, italicContent) {
13 if (codeBlock) {13 if (tripleBackticks || singleOrDoubleBackticks) {
14 // If it's a code block, return it unchanged14 // If it's any kind of code block, return it unchanged
15 return match;15 return match;
16 } else {16 } else if (italicContent) {
17 // If it's an italic group, apply the replacement17 // If it's an italic group, apply the replacement
18 return `<em>${italicContent}</em>`;18 return '<em>' + italicContent + '</em>';
19 }19 }
20 // If neither condition is met, return the original match
21 return match;
20 },22 },
21 }];23 }];
22 } catch (e) {24 } catch (e) {