You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
==> Preparing: select * from user where id=?
==> Parameters: 1(Integer)
<== Columns: id, username
<== Row: 1, tyw
<== Total: 1
User{id=1, username='tyw'}
解决
functionreplaceMarks(md){// 匹配代码块letcodeBlockRegex=/```[\s\S]*?```/g;// 将代码块替换为占位符,避免在后续处理中受到影响letplaceholders=[];md=md.replace(codeBlockRegex,function(match){letplaceholder=`CODE_BLOCK_${placeholders.length}`;placeholders.push(match);returnplaceholder;});// 匹配行内代码块letinlineCodeRegex=/`[^`]*`/g;letinlineCodePlaceholders=[];md=md.replace(inlineCodeRegex,function(match){letplaceholder=`INLINE_CODE_${inlineCodePlaceholders.length}`;inlineCodePlaceholders.push(match);returnplaceholder;});// 正则表达式,匹配严格符合 == 开始和结束的部分,但不在代码块和行内代码块内letregex=/(?<!`|```)==([^=]+)==(?!.*(?:`|```))(?!.*INLINE_CODE_\d+)/g;// 替换非代码块和行内代码块内的 == 部分md=md.replace(regex,'<span style="font-weight: bold;" class="mark">$1</span>');// 将代码块恢复回去for(leti=0;i<placeholders.length;i++){md=md.replace(`CODE_BLOCK_${i}`,placeholders[i]);}// 将行内代码块恢复回去for(leti=0;i<inlineCodePlaceholders.length;i++){md=md.replace(`INLINE_CODE_${i}`,inlineCodePlaceholders[i]);}returnmd;}// 测试函数letmd=`==This should be bold==\`\`\`javascript// This is a code blocklet x = 10;console.log(x);\`\`\`This is an `inlinecodeblock`.==This should also be bold==`;letprocessedMd=replaceMarks(md);console.log(processedMd);
The text was updated successfully, but these errors were encountered:
解决
The text was updated successfully, but these errors were encountered: