@@ -6021,8 +6021,8 @@ Current version indicated by LITEVER below.
60216021 };
60226022 const replaceLatex = (input) =>{
60236023 //all latex patterns except inline tex
6024- input = input.replace(/(^```math\n([\s\S]*?)\n```$|^ {0,6}\\\[\n([\s\S]*?)\n {0,6}\\\]$|^\$\$\n([\s\S]*?)\n\$\$$|\$\$([ ^\n]+?)\$\$|\\\(([^\n]+?)\\\)|\\\[([^\n]+?)\\\])/gm, (match, p1, p2, p3, p4, p5, p6, p7) => {
6025- let content = p2 || p3 || p4 || p5 || p6 || p7;
6024+ input = input.replace(/(^```math\n([\s\S]*?)\n```$|^ {0,6}\\\[\n([\s\S]*?)\n {0,6}\\\]$|^\$\$\n([\s\S]*?)\n\$\$$|^ {2} \$\$\n {2}([\s\S]*?)\n {2}\$\$$|\$\$([ ^\n]+?)\$\$|\\\(([^\n]+?)\\\)|\\\[([^\n]+?)\\\])/gm, (match, p1, p2, p3, p4, p5, p6, p7, p8 ) => {
6025+ let content = p2 || p3 || p4 || p5 || p6 || p7 || p8 ;
60266026 const matchedlw = match.match(/^[ \t]*/);
60276027 const leadingWhitespace = matchedlw ? matchedlw[0] : '';
60286028 content = unescape_html(content);
@@ -6032,23 +6032,32 @@ Current version indicated by LITEVER below.
60326032 }
60336033 return leadingWhitespace + temml.renderToString(content); // render LaTeX content
60346034 });
6035- input = input.replace(/(?: ^|[^\\])\$(\S[^$\n]*?\S)\$(?!\d)/g, (match, p1) => {
6035+ input = input.replace(/(^|[^\\])\$(\S[^$\n]*?\S)\$(?!\d)/g, (match, prefix , p1) => {
60366036 let content = p1;
60376037 content = unescape_html(content);
60386038 if(content.replace(/\s+/g, '').match(/^\${1,}$/)) //only dollar signs, just return
60396039 {
60406040 return match;
60416041 }
6042- return " " +temml.renderToString(content); // render LaTeX content
6042+ return prefix +temml.renderToString(content); // render LaTeX content
60436043 });
6044- input = input.replace(/(?: ^|[^\\])\$ (\S[^$\n$]*?\S) \$(?!\d)/g, (match, p1) => { //special version that handles a single space on both sides
6044+ input = input.replace(/(^|[^\\])\$([A-Za-z0-9]) \$(?!\d)/g, (match, prefix, p1) => { //single letter or number
60456045 let content = p1;
60466046 content = unescape_html(content);
60476047 if(content.replace(/\s+/g, '').match(/^\${1,}$/)) //only dollar signs, just return
60486048 {
60496049 return match;
60506050 }
6051- return " "+temml.renderToString(content); // render LaTeX content
6051+ return prefix+temml.renderToString(content); // render LaTeX content
6052+ });
6053+ input = input.replace(/(^|[^\\])\$ (\S[^$\n]*?) \$(?!\d)/g, (match, prefix, p1) => { //special version that handles a single space on both sides
6054+ let content = p1;
6055+ content = unescape_html(content);
6056+ if(content.replace(/\s+/g, '').match(/^\${1,}$/)) //only dollar signs, just return
6057+ {
6058+ return match;
6059+ }
6060+ return prefix+temml.renderToString(content); // render LaTeX content
60526061 });
60536062 input = input.replace(/(^\\begin\{math\}\n([\s\S]*?)\n\\end\{math\}$|^\\begin\{equation\}\n([\s\S]*?)\n\\end\{equation\}$)/gm, (match, p1, p2, p3) => { //match math eqns
60546063 let content = p2 || p3;
0 commit comments