From ce1ba8289c4e7d0a162ed99750f40a153771514f Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 6 Nov 2023 22:30:26 -0600 Subject: [PATCH] Add Multi-line Dictionary Definition (
) rows. Expands the existing syntax to allow/expect the option of multiple definitions by adding any number of ``` :: Definition``` to an a DT/DD set. --- shared/naturalcrit/markdown.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 114229887..900475986 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -218,8 +218,9 @@ const definitionLists = { while (match = regex.exec(src)) { definitions.push({ dt : this.lexer.inlineTokens(match[1].trim()), - dd : this.lexer.inlineTokens(match[2].trim()) + dd : match[2].split('::').map((s)=>this.lexer.inlineTokens(s.trim())) }); + console.log(match.splice(2).map((s)=>s.trim())); endIndex = regex.lastIndex; } if(definitions.length) { @@ -232,8 +233,9 @@ const definitionLists = { }, renderer(token) { return `
${token.definitions.reduce((html, def)=>{ - return `${html}
${this.parser.parseInline(def.dt)}
` - + `
${this.parser.parseInline(def.dd)}
\n`; + const dds = def.dd.map((s)=>`
${this.parser.parseInline(s)}
`).join('\n'); + return `${html}
${this.parser.parseInline(def.dt)}
+ ${dds}`; }, '')}
`; } };