Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (node.nodeType !== 1 || node.tagName !== 'FIGURE') {
return;
}
let pre = node.querySelector('pre');
let code = pre.querySelector('code');
let figcaption = node.querySelector('figcaption');
// if there's no caption the preCodeToCard plugin will pick it up instead
if (!code || !figcaption) {
return;
}
let payload = {
code: code.textContent,
caption: cleanBasicHtml(figcaption.innerHTML, options)
};
let preClass = pre.getAttribute('class') || '';
let codeClass = code.getAttribute('class') || '';
let langRegex = /lang(?:uage)?-(.*?)(?:\s|$)/i;
let languageMatches = preClass.match(langRegex) || codeClass.match(langRegex);
if (languageMatches) {
payload.language = languageMatches[1].toLowerCase();
}
let cardSection = builder.createCardSection('code', payload);
addSection(cardSection);
nodeFinished();
}
cleanHTML: computed('html', function () {
return cleanBasicHtml(this.html);
}),
export function cleanBasicHtmlHelper(html = '') {
if (isArray(html)) {
html = html[0] || '';
}
return cleanBasicHtml(html);
}
}
let payload = {
src: img.src,
alt: img.alt,
title: img.title
};
if (kgClass) {
payload.cardWidth = kgClass[1];
} else if (grafClass) {
payload.cardWidth = grafClass[1] === 'FillWidth' ? 'full' : 'wide';
}
if (figcaption) {
let cleanHtml = cleanBasicHtml(figcaption.innerHTML, options);
payload.caption = cleanHtml;
}
let cardSection = builder.createCardSection('image', payload);
addSection(cardSection);
nodeFinished();
}
_getHTML() {
if (this.editor && this.editor.element) {
let firstParagraph = this.editor.element.querySelector('p');
if (!firstParagraph) {
return '';
}
let html = firstParagraph.innerHTML;
return cleanBasicHtml(html);
}
}
});