0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 14:12:40 +00:00

give span tags to injection syntax for styling

This commit is contained in:
Gazook89
2022-11-13 21:02:45 -06:00
parent 5f2115da0e
commit cc58721ccd
2 changed files with 22 additions and 0 deletions

View File

@@ -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;

View File

@@ -29,6 +29,10 @@
font-weight : bold;
//font-style: italic;
}
.injection{
color : green;
font-weight : bold;
}
}
.brewJump{