mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 01:42:42 +00:00
Fix issue when pattern matches a DD without DT
``` Test ::One ``` WOuld previously break the browser.
This commit is contained in:
@@ -243,17 +243,19 @@ const definitionLists = {
|
|||||||
let match;
|
let match;
|
||||||
const endIndex = src.match(`\n\n`)?.index + 2;
|
const endIndex = src.match(`\n\n`)?.index + 2;
|
||||||
const allDefinitions = [];
|
const allDefinitions = [];
|
||||||
let currentDefinition = [];
|
let currentDefinition = {};
|
||||||
while (match = regex.exec(src)) {
|
while (match = regex.exec(src)) {
|
||||||
if(match[1].trim()?.length) {
|
if(match[1].trim()?.length) {
|
||||||
if(currentDefinition?.dt?.length) {
|
if(currentDefinition?.dt?.length) {
|
||||||
allDefinitions.push(currentDefinition);
|
allDefinitions.push(currentDefinition);
|
||||||
currentDefinition = [];
|
currentDefinition = {};
|
||||||
}
|
}
|
||||||
currentDefinition = {
|
currentDefinition = {
|
||||||
dt : this.lexer.inlineTokens(match[1].trim()),
|
dt : this.lexer.inlineTokens(match[1].trim()),
|
||||||
dd : []
|
dd : []
|
||||||
};
|
};
|
||||||
|
} else if(_.isEmpty(currentDefinition)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
currentDefinition.dd = currentDefinition.dd.concat(match[2].split('::').filter((item)=>item).map((s)=>this.lexer.inlineTokens(s.trim())));
|
currentDefinition.dd = currentDefinition.dd.concat(match[2].split('::').filter((item)=>item).map((s)=>this.lexer.inlineTokens(s.trim())));
|
||||||
if(!currentDefinition.dd?.length) {
|
if(!currentDefinition.dd?.length) {
|
||||||
@@ -273,7 +275,7 @@ const definitionLists = {
|
|||||||
let returnVal = `<dl>`;
|
let returnVal = `<dl>`;
|
||||||
token.definitions.forEach((def)=>{
|
token.definitions.forEach((def)=>{
|
||||||
const dds = def.dd.map((s)=>`<dd>${this.parser.parseInline(s)}</dd>`).join('\n');
|
const dds = def.dd.map((s)=>`<dd>${this.parser.parseInline(s)}</dd>`).join('\n');
|
||||||
returnVal += `<div><dt>${this.parser.parseInline(def.dt)}</dt>${dds}</div>`;
|
returnVal += `<dt>${this.parser.parseInline(def.dt)}</dt>\n${dds}\n`;
|
||||||
});
|
});
|
||||||
return `${returnVal}</dl>`;
|
return `${returnVal}</dl>`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user