我有一个texteareacalled note_text,一个divcallednote_preview和这个函数:
function fence_math(text) {
return text
.replace(new RegExp('\\\((.*?)\\\)', 'g'), '`memviv-math $1`')
.replace(new RegExp('\\\[(.*?)\\\]', 'g'), '`memviv-equation $1`');
}
如果我运行这个:
note_preview.innerHTML = fence_math(note_text.value);
当note_text包含
\(a *b* c\)
我得到
<div id="note_preview">\`memviv-math a *b* c\`</div>
为什么重音符号前有反斜杠?我会期望:
<div id="note_preview">`memviv-math a *b* c`</div>
我该怎么做才能得到正确的结果?
鸿蒙传说
相关分类