0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-04-01 05:18:11 +00:00

proper highlights for weird def lists

This commit is contained in:
Víctor Losada Hernández
2026-03-29 01:59:21 +01:00
parent d2ca8473f3
commit 4aa9408358

View File

@@ -79,20 +79,15 @@ export function tokenizeCustomMarkdown(text) {
}
}
// --- inline definition lists ---
if(/::/.test(lineText)) {
if(/^:*$/.test(lineText) == true) {
return; //if line only has colons, stops
}
const singleLineRegex = /^([^:\n]*\S)\s*(::)([^\n]*)$/dmy;
const singleLineRegex = /^([^:\n]*\S)(\s*)(::)([^\n]*)$/dmy;
const match = singleLineRegex.exec(lineText);
if(match) {
const [full, term, colons, desc] = match;
const [full, term, spaces, colons, desc] = match;
let offset = 0;
// Entire line as definitionList
tokens.push({
line : lineNumber,
type : customTags.definitionList,
@@ -107,7 +102,12 @@ export function tokenizeCustomMarkdown(text) {
});
offset += term.length;
// ::
// Spaces before ::
if(spaces) {
offset += spaces.length;
}
// :: colons
tokens.push({
line : lineNumber,
type : customTags.definitionColon,
@@ -126,7 +126,6 @@ export function tokenizeCustomMarkdown(text) {
return;
}
}
// multiline def list
if(!/^::/.test(lines[lineNumber]) && lineNumber + 1 < lines.length && /^::/.test(lines[lineNumber + 1])) {
@@ -254,7 +253,6 @@ export function tokenizeCustomCSS(text) {
return tokens;
}
console.log(tags);
//assign classes to tags provided by lezer, not unlike the function above
export const customHighlightStyle = HighlightStyle.define([
{ tag: tags.heading, class: 'cm-header' },