From f1e6a9a41e61025d7ba4807f4ea032cc314e740d Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Wed, 27 Sep 2023 22:45:36 -0500 Subject: [PATCH] add syntax highlighting for definition lists --- client/homebrew/editor/editor.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index d6502e985..b4f1fc824 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -149,6 +149,17 @@ const Editor = createClass({ codeMirror.addLineClass(lineNumber, 'text', 'columnSplit'); } + // definition lists + if(line.includes('::')){ + 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' }); + } + } + // Highlight injectors {style} if(line.includes('{') && line.includes('}')){ const regex = /(?:^|[^{\n])({(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\2})/gm;