koenig/kg-clean-basic-html/README.md
Sanitises and normalises the basic HTML snippets used in Ghost's editor cards, such as captions.
npm install @tryghost/kg-clean-basic-html
import {cleanBasicHtml} from '@tryghost/kg-clean-basic-html';
cleanBasicHtml(' <p>Hello <b>world</b></p> ');
// '<p>Hello <b>world</b></p>'
In the browser the document is taken from the global document. In Node you
must supply one, or the call throws:
import {JSDOM} from 'jsdom';
cleanBasicHtml(html, {
createDocument: htmlString => new JSDOM(htmlString).window.document
});
This package is part of the Ghost monorepo
and resolves through the pnpm workspace — there is no linking or per-package
install step. Run pnpm setup in the monorepo root, then work in
koenig/kg-clean-basic-html.
See the Koenig README for the shared build, test and release workflow.
pnpm test:unit runs the unit testspnpm test runs the unit and type tests, including coverage thresholdspnpm lint runs the lint checksCopyright (c) 2013-2026 Ghost Foundation - Released under the MIT license.