diff --git a/packages/core/src/html/MdAttributeRenderer.js b/packages/core/src/html/MdAttributeRenderer.js index 0d3c8a1a7f..3e6bfe738a 100644 --- a/packages/core/src/html/MdAttributeRenderer.js +++ b/packages/core/src/html/MdAttributeRenderer.js @@ -1,5 +1,6 @@ const cheerio = require('cheerio'); +const { createSlotTemplateNode } = require('./elements'); const { getVslotShorthandName } = require('./vueSlotSyntaxProcessor'); const _ = {}; @@ -35,8 +36,7 @@ class MdAttributeRenderer { rendered = this.markdownProcessor.renderMd(node.attribs[attribute]); } - const attributeSlotElement = cheerio.parseHTML( - ``, true); + const attributeSlotElement = createSlotTemplateNode(slotName, rendered); node.children = node.children ? attributeSlotElement.concat(node.children) : attributeSlotElement; } @@ -114,17 +114,17 @@ class MdAttributeRenderer { */ processQuestion(node) { - this.processAttributeWithoutOverride(node, 'header', false, 'header'); - this.processAttributeWithoutOverride(node, 'hint', false, 'hint'); - this.processAttributeWithoutOverride(node, 'answer', false, 'answer'); + this.processAttributeWithoutOverride(node, 'header', false); + this.processAttributeWithoutOverride(node, 'hint', false); + this.processAttributeWithoutOverride(node, 'answer', false); } processQOption(node) { - this.processAttributeWithoutOverride(node, 'reason', false, 'reason'); + this.processAttributeWithoutOverride(node, 'reason', false); } processQuiz(node) { - this.processAttributeWithoutOverride(node, 'intro', false, 'intro'); + this.processAttributeWithoutOverride(node, 'intro', false); } /* @@ -132,7 +132,7 @@ class MdAttributeRenderer { */ processTabAttributes(node) { - this.processAttributeWithoutOverride(node, 'header', true, 'header'); + this.processAttributeWithoutOverride(node, 'header', true); } /* @@ -140,8 +140,8 @@ class MdAttributeRenderer { */ processBoxAttributes(node) { - this.processAttributeWithoutOverride(node, 'icon', true, 'icon'); - this.processAttributeWithoutOverride(node, 'header', false, 'header'); + this.processAttributeWithoutOverride(node, 'icon', true); + this.processAttributeWithoutOverride(node, 'header', false); } /* @@ -149,19 +149,9 @@ class MdAttributeRenderer { */ processDropdownAttributes(node) { - const hasHeaderSlot = node.children - && node.children.some(child => getVslotShorthandName(child) === 'header'); - - // If header slot is present, the header attribute has no effect, and we can simply remove it. - if (hasHeaderSlot) { - if (_.has(node.attribs, 'header')) { - logger.warn(`${node.name} has a header slot, 'header' attribute has no effect.`); - } - delete node.attribs.header; - return; + if (!this.hasSlotOverridingAttribute(node, 'header')) { + this.processAttributeWithoutOverride(node, 'header', true); } - - this.processAttributeWithoutOverride(node, 'header', true, 'header'); } /** diff --git a/packages/core/src/html/includePanelProcessor.js b/packages/core/src/html/includePanelProcessor.js index 50c8194963..d32d0c1982 100644 --- a/packages/core/src/html/includePanelProcessor.js +++ b/packages/core/src/html/includePanelProcessor.js @@ -134,7 +134,7 @@ function processPanelSrc(node, context, pageSources, config) { asIfTo: filePath, }); - return node; + return context; } /* @@ -168,6 +168,7 @@ function processInclude(node, context, pageSources, variableProcessor, renderMd, const error = new Error(`Empty src attribute in include in: ${context.cwf}`); logger.error(error); cheerio(node).replaceWith(createErrorNode(node, error)); + return context; } const { @@ -177,6 +178,12 @@ function processInclude(node, context, pageSources, variableProcessor, renderMd, actualFilePath, } = _getSrcFlagsAndFilePaths(node, config); + // No need to process url contents + if (isUrl) { + _deleteIncludeAttributes(node); + return context; + } + const isOptional = _.has(node.attribs, 'optional'); const fileExistsNode = _getFileExistsNode(node, context, actualFilePath, pageSources, isOptional); if (fileExistsNode) { @@ -189,12 +196,6 @@ function processInclude(node, context, pageSources, variableProcessor, renderMd, node.name = isInline ? 'span' : 'div'; - // No need to process url contents - if (isUrl) { - _deleteIncludeAttributes(node); - return node; - } - pageSources.staticIncludeSrc.push({ from: context.cwf, to: actualFilePath, @@ -247,6 +248,7 @@ function processInclude(node, context, pageSources, variableProcessor, renderMd, const error = new CyclicReferenceError(childContext.callStack); logger.error(error); cheerio(node).replaceWith(createErrorNode(node, error)); + return context; } }