0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-07 16:38:38 +00:00

Simplify regex, fix crash on empty desc.length, only highlight if there is a Term line with content

This commit is contained in:
Trevor Buckner
2026-04-23 14:36:55 -04:00
parent c341e8ffdc
commit 4fee82d3b7
@@ -137,14 +137,14 @@ export function tokenizeCustomMarkdown(text) {
for (let i = lineNumber + 1; i < lines.length; i++) { for (let i = lineNumber + 1; i < lines.length; i++) {
const nextLine = lines[i]; const nextLine = lines[i];
const onlyColonsMatch = /^:*$/.test(nextLine); const onlyColonsMatch = /^:*$/.test(nextLine);
const defMatch = /^(::)(.*\S.*)?\s*$/.exec(nextLine); const defMatch = /^(::)(.+)$/.exec(nextLine);
if(!onlyColonsMatch && defMatch) { if(!onlyColonsMatch && defMatch) {
defs.push({ colons: defMatch[1], desc: defMatch[2], line: i }); defs.push({ colons: defMatch[1], desc: defMatch[2], line: i });
endLine = i; endLine = i;
} else break; } else break;
} }
if(defs.length > 0) { if(defs.length > 0 && lineText.trim().length > 0) {
tokens.push({ tokens.push({
line : startLine, line : startLine,
type : customTags.definitionList, type : customTags.definitionList,
@@ -175,7 +175,7 @@ export function tokenizeCustomMarkdown(text) {
line : d.line, line : d.line,
type : customTags.definitionDesc, type : customTags.definitionDesc,
from : d.colons.length, from : d.colons.length,
to : d.colons.length + d.desc.length, to : d.colons.length + d.desc?.length,
}); });
}); });
} }