0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-31 19:32:47 +00:00

Implementing magic item snippet from Issue 671. (#842)

* Implementing magic item snippet from Issue 671.

* Fixes syntax errors. Function moved into existing magic module.

* Implementing magic item snippet from Issue 671.

* Fixes syntax errors. Function moved into existing magic module.

* Magic Item Snippet, <dl>, `:` for blank line

Co-authored-by: Trevor Buckner <calculuschild@gmail.com>
This commit is contained in:
Christian Brickhouse
2021-02-24 18:58:11 -08:00
committed by GitHub
parent 468b7319d1
commit 68811eb3fc
7 changed files with 110 additions and 44 deletions

View File

@@ -109,21 +109,14 @@ const Editor = createClass({
r.push(lineNumber);
}
if(line.startsWith('\\column')){
if(line.match(/^\\column$/)){
codeMirror.addLineClass(lineNumber, 'text', 'columnSplit');
r.push(lineNumber);
}
if(line.startsWith('{{') || line.startsWith('}}')){
let endCh = line.length+1;
const match = line.match(/{{(?:[\w,#-]|="[\w, ]*")*\s*|}}/);
if(match)
endCh = match.index+match[0].length;
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
}
// Highlight inline spans {{content}}
if(line.includes('{{') && line.includes('}}')){
const regex = /{{(?:[\w,#-]|="[\w, ]*")*\s*|}}/g;
const regex = /{{(?:="[\w,\-. ]*"|[^"'\s])*\s*|}}/g;
let match;
let blockCount = 0;
while ((match = regex.exec(line)) != null) {
@@ -138,6 +131,14 @@ const Editor = createClass({
}
codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'inline-block' });
}
} else if(line.trimLeft().startsWith('{{') || line.trimLeft().startsWith('}}')){
// Highlight block divs {{\n Content \n}}
let endCh = line.length+1;
const match = line.match(/^ *{{(?:="[\w,\-. ]*"|[^"'\s])*$|^ *}}$/);
if(match)
endCh = match.index+match[0].length;
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
}
}