Fixed crash on no 'externalContext' in md files.
This commit is contained in:
parent
7fa8f0b308
commit
4529f395fd
|
@ -1,6 +1,10 @@
|
|||
export function parseExternalContext(externalContext) {
|
||||
// Remove start and end tag
|
||||
externalContext = externalContext.replace(/%%-\n|-%%\n/g, "")
|
||||
// If there's no external context, return nothing.
|
||||
if (!externalContext)
|
||||
return {}
|
||||
|
||||
// Remove start and end tag ↓ Only care about the first "externalConext"
|
||||
externalContext = externalContext[0].replace(/%%-\n|-%%\n/g, "")
|
||||
|
||||
let parsedContext = {}
|
||||
externalContext.split("\n").forEach(line => {
|
||||
|
|
|
@ -24,7 +24,7 @@ export function mdRenderer(path) {
|
|||
|
||||
// Separate the actual markdown from potential 'externalContext'
|
||||
const externalMarkdown = externalMarkdownFile.replace(/^%%-\n[\S\s]*-%%\n/, "").replace(/```\w*[\s\S]*?```/g, match => match.replace(/ /g, "•"))
|
||||
const externalContext = externalMarkdownFile.match(/^%%-\n[\S\s]*-%%\n/)[0]
|
||||
const externalContext = externalMarkdownFile.match(/^%%-\n[\S\s]*-%%\n/)
|
||||
|
||||
// Pre-render the template for analysis during context generation.
|
||||
const prerenderedNjk = njk.renderString(njkFile, { externalMarkdown })
|
||||
|
|
Loading…
Reference in New Issue
Block a user