diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index c4df7a89c..637394072 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -161,20 +161,20 @@ const Editor = createClass({ } // Superscript - if(line.includes('^^') && !line.includes('^^^')) { - const regex = /.*\^\^(.+)\^\^/y; + if(line.includes('\^')) { + const regex = /\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/g; let match; while ((match = regex.exec(line)) != null) { - codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) - 2 }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length + 2 }, { className: 'superscript' }); + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) - 1 }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length + 1 }, { className: 'superscript' }); } } // Subscript - if(line.includes('^^^')) { - const regex = /.*\^\^\^(.+)\^\^\^/y; + if(line.includes('^^')) { + const regex = /\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/g; let match; while ((match = regex.exec(line)) != null) { - codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) - 3 }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length + 3 }, { className: 'subscript' }); + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) - 2 }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length + 2 }, { className: 'subscript' }); } }