package
HTML parsing, filtering and serialization logic extracted from TinyMCE
npm install tinymce.htmlGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
189.0 kB
Includes dependencies.
TinyMCE includes sophisticated logic for cleaning up HTML content. What's interesting about this logic is that it's pure JavaScript. It doesn't use any browser-specific APIs and can be used with Node.js.
Versions follow TinyMCE's, except 4.5.3: it's TinyMCE 4.5.2 plus a fix for
attribute values longer than ~500k characters (e.g. big data: images), which
were lost in Safari and other JavaScriptCore-based environments.
var tinymce = require('tinymce.html');
var schema = new tinymce.html.Schema({
valid_elements: "@[class],#p,span,a[!href],strong/b",
valid_classes: "foo"
});
var parser = new tinymce.html.Parser({
forced_root_block: 'p'
}, schema);
var serializer = new tinymce.html.Serializer({
indent: true,
indent_before: 'p',
indent_after: 'p'
}, schema);
var html = '<B title="title" class="foo bar">test</B><a href="//tinymce.com">' +
Schema:
valid_elementsvalid_classesvalid_childrenvalid_styles (use tinymce.html.Parser for this option to work, not )tinymce.html.DomParserschema ("html5", "html4", "html5-strict")Parser:
Serializer:
indentindent_beforeindent_after