mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-29 12:08:12 +00:00
proper highlights for weird def lists
This commit is contained in:
@@ -79,20 +79,15 @@ export function tokenizeCustomMarkdown(text) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- inline definition lists ---
|
const singleLineRegex = /^([^:\n]*\S)(\s*)(::)([^\n]*)$/dmy;
|
||||||
if(/::/.test(lineText)) {
|
|
||||||
if(/^:*$/.test(lineText) == true) {
|
|
||||||
return; //if line only has colons, stops
|
|
||||||
}
|
|
||||||
|
|
||||||
const singleLineRegex = /^([^:\n]*\S)\s*(::)([^\n]*)$/dmy;
|
|
||||||
|
|
||||||
const match = singleLineRegex.exec(lineText);
|
const match = singleLineRegex.exec(lineText);
|
||||||
|
|
||||||
if(match) {
|
if(match) {
|
||||||
const [full, term, colons, desc] = match;
|
const [full, term, spaces, colons, desc] = match;
|
||||||
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
// Entire line as definitionList
|
|
||||||
tokens.push({
|
tokens.push({
|
||||||
line : lineNumber,
|
line : lineNumber,
|
||||||
type : customTags.definitionList,
|
type : customTags.definitionList,
|
||||||
@@ -107,7 +102,12 @@ export function tokenizeCustomMarkdown(text) {
|
|||||||
});
|
});
|
||||||
offset += term.length;
|
offset += term.length;
|
||||||
|
|
||||||
// ::
|
// Spaces before ::
|
||||||
|
if(spaces) {
|
||||||
|
offset += spaces.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// :: colons
|
||||||
tokens.push({
|
tokens.push({
|
||||||
line : lineNumber,
|
line : lineNumber,
|
||||||
type : customTags.definitionColon,
|
type : customTags.definitionColon,
|
||||||
@@ -126,7 +126,6 @@ export function tokenizeCustomMarkdown(text) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// multiline def list
|
// multiline def list
|
||||||
if(!/^::/.test(lines[lineNumber]) && lineNumber + 1 < lines.length && /^::/.test(lines[lineNumber + 1])) {
|
if(!/^::/.test(lines[lineNumber]) && lineNumber + 1 < lines.length && /^::/.test(lines[lineNumber + 1])) {
|
||||||
@@ -254,7 +253,6 @@ export function tokenizeCustomCSS(text) {
|
|||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(tags);
|
|
||||||
//assign classes to tags provided by lezer, not unlike the function above
|
//assign classes to tags provided by lezer, not unlike the function above
|
||||||
export const customHighlightStyle = HighlightStyle.define([
|
export const customHighlightStyle = HighlightStyle.define([
|
||||||
{ tag: tags.heading, class: 'cm-header' },
|
{ tag: tags.heading, class: 'cm-header' },
|
||||||
|
|||||||
Reference in New Issue
Block a user