towxml icon indicating copy to clipboard operation
towxml copied to clipboard

我想请问 公式怎么能匹配 \( \) 这种的行内和块级公式

Open Zeeyuann opened this issue 1 year ago • 1 comments

Zeeyuann avatar Nov 07 '24 02:11 Zeeyuann

方法一:简单粗暴,用正则匹配替换成所需格式,行内$latex$或者块级$$latex$$

str.replace(/\\\(\s*(.*?)\s*\\\)/g, "$$$1$$") // 行公式规则转换
    .replace(/\\\[\s*(.*?)\s*\\\]/g, "$$$$$1$$$$") // 块公式规则转换

方法二: 改源码这里的匹配逻辑 towxml/parse/markdown/plugins/latex.js 会涉及到转义字符,还需要改移动的步数

chenqiuling avatar Nov 12 '24 05:11 chenqiuling