INNER CODE UNIT · JavaScript

sanitize_to_dom

danburzo/percollate · src/cleanup-item.js:148

	const sanitize_to_dom = dirty =>
		Array.from(sanitizer.sanitize(dirty, { RETURN_DOM: true }).children);

	const content_els = sanitize_to_dom(parsed.content);

	// `--toc-level` implies `--toc`, unless disabled with `--no-toc`.
	let headings = [];
	if (options['toc-level'] > 1 && options.toc !== false) {
		headings = setIdsAndReturnHeadings(
			content_els,
			options['toc-level']
		).map(heading => {
			return {
				id: heading.id,
				level: heading.level,
				// Plain text used in EPUB
				text: heading.node.textContent.trim(),
				// Sanitized marked-up text used in HTML/PDF

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…