From cc58721ccdd32c18a17109c9f89d5762508fd5f5 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Sun, 13 Nov 2022 21:02:45 -0600 Subject: [PATCH] give span tags to injection syntax for styling --- client/homebrew/editor/editor.jsx | 18 ++++++++++++++++++ client/homebrew/editor/editor.less | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index d05d5cc0d..947ae7b7f 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -137,6 +137,24 @@ const Editor = createClass({ codeMirror.addLineClass(lineNumber, 'text', 'columnSplit'); } + + if(line.includes('{') && line.includes('}')){ + const regex = /{(?:(?=(:(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*))\1)*}/g; + let match; + let blockCount = 0; + while ((match = regex.exec(line)) != null) { + if(match[0].startsWith('{')) { + blockCount += 1; + } else { + blockCount -= 1; + } + if(blockCount < 0) { + blockCount = 0; + continue; + } + codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'injection' }); + } + } // Highlight inline spans {{content}} if(line.includes('{{') && line.includes('}}')){ const regex = /{{(?:(?=(:(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*))\1)*|}}/g; diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index 810ee1710..b8f978ba3 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -29,6 +29,10 @@ font-weight : bold; //font-style: italic; } + .injection{ + color : green; + font-weight : bold; + } } .brewJump{