0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 06:52:41 +00:00

Update class Features snippet to v3

Puts adjacent `term :: definition` s into the same `dl` block for easier spacing of sets of terms.
This commit is contained in:
Trevor Buckner
2021-09-11 21:52:37 -04:00
parent cd0b659653
commit 82b9f825d5
3 changed files with 34 additions and 38 deletions

View File

@@ -208,7 +208,7 @@ const definitionLists = {
level : 'block',
start(src) { return src.match(/^.*?::.*/m)?.index; }, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
const regex = /^([^\n]*?)::([^\n]*)/ym;
const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym;
let match;
let endIndex = 0;
const definitions = [];
@@ -228,12 +228,10 @@ const definitionLists = {
}
},
renderer(token) {
return `<dl>
${token.definitions.reduce((html, def)=>{
return `${html}<dt>${this.parser.parseInline(def.dt)}</dt>`
+ `<dd>${this.parser.parseInline(def.dd)}</dd>\n`;
}, '')}
</dl>`;
return `<dl>${token.definitions.reduce((html, def)=>{
return `${html}<dt>${this.parser.parseInline(def.dt)}</dt>`
+ `<dd>${this.parser.parseInline(def.dd)}</dd>\n`;
}, '')}</dl>`;
}
};