How to use @tryghost/kg-clean-basic-html - 5 common examples

To help you get started, we’ve selected a few @tryghost/kg-clean-basic-html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gazooka / GhostInAzureWebApp / node_modules / @tryghost / kg-parser-plugins / lib / parser-plugins.js View on Github external
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();
    }
github TryGhost / Ghost-Admin / lib / koenig-editor / addon / components / koenig-basic-html-input.js View on Github external
cleanHTML: computed('html', function () {
        return cleanBasicHtml(this.html);
    }),
github TryGhost / Ghost-Admin / lib / koenig-editor / addon / helpers / clean-basic-html.js View on Github external
export function cleanBasicHtmlHelper(html = '') {
    if (isArray(html)) {
        html = html[0] || '';
    }

    return cleanBasicHtml(html);
}
github gazooka / GhostInAzureWebApp / node_modules / @tryghost / kg-parser-plugins / lib / parser-plugins.js View on Github external
}

        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();
    }
github TryGhost / Ghost-Admin / lib / koenig-editor / addon / components / koenig-basic-html-input.js View on Github external
_getHTML() {
        if (this.editor && this.editor.element) {
            let firstParagraph = this.editor.element.querySelector('p');

            if (!firstParagraph) {
                return '';
            }

            let html = firstParagraph.innerHTML;
            return cleanBasicHtml(html);
        }
    }
});

@tryghost/kg-clean-basic-html

MIT
Latest version published 2 months ago

Package Health Score

66 / 100
Full package analysis

Popular @tryghost/kg-clean-basic-html functions

Similar packages