Node's Pretty Magical

    tinymce.html

    4.5.2 • Public • Published

    tinymce.html

    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.

    Build Status npm

    Example

    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">' +
        'TinyMCE</a><p>Lorem <a>Ipsum</a></p>';
    var root = parser.parse(initialHtml);
    var result = serializer.serialize(root);
     
    console.log(result);
    // <p><strong class="foo">test</strong><a href="//tinymce.com">TinyMCE</a></p>
    // <p>Lorem Ipsum</p>

    Options

    Links

    Install

    npm i tinymce.html

    DownloadsWeekly Downloads

    10

    Version

    4.5.2

    License

    LGPL-2.1

    Last publish

    Collaborators

    • thorn0