From e6428a3b18220c30ac2c244a069e4f8118e022f1 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Tue, 7 Nov 2023 18:07:11 -0600 Subject: [PATCH] Update Editor highlighting for Definition Lists Fixes syntax highlighting to account for multiple definitions on a definition list. --- client/homebrew/editor/editor.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index b4f1fc824..cf762974e 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -154,9 +154,14 @@ const Editor = createClass({ const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym; let match; while ((match = regex.exec(line)) != null){ + codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[0]) }, { line: lineNumber, ch: line.indexOf(match[0]) + match[0].length }, { className: 'define' }); codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'term' }); - codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[2]) }, { line: lineNumber, ch: line.indexOf(match[2]) + match[2].length }, { className: 'definition' }); + const matches = match[2].split('::').map((s)=>(s.trim())); + matches.forEach((m)=>{ + codeMirror.markText({ line: lineNumber, ch: line.indexOf(m) }, { line: lineNumber, ch: line.indexOf(m) + m.length }, { className: 'definition' }); + }); + // codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[2]) }, { line: lineNumber, ch: line.indexOf(match[2]) + match[2].length }, { className: 'definition' }); } }