How to use the htmlparser2.parseDOM function in htmlparser2

To help you get started, we’ve selected a few htmlparser2 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 LLK / scratch-vm / src / engine / adapter.js View on Github external
const adapter = function (e) {
    // Validate input
    if (typeof e !== 'object') return;
    if (typeof e.xml !== 'object') return;

    return domToBlocks(html.parseDOM(e.xml.outerHTML));
};
github ecomfe / htmlcs / test / lib / node.spec.js View on Github external
describe('node methods (read ops)', function () {
    var p = htmlparser2.parseDOM(
        '<p><span></span>'
        + '<a disabled="" data-role="test" href="#" class="y z" id="x">'
        + '<img class="cls" id="c1">'
        + '<span class="cls" id="c2"></span>'
        + '</a>'
        + '<i></i></p>'
    )[0];

    var p2 = htmlparser2.parseDOM('<p></p>')[0];

    transformRecursively(p);
    transformRecursively(p2);

    it('should have node methods', function () {

        var node = p.childNodes[1];

        expect(node.hasChildNodes()).toBe(true);
        expect(node.firstChild.hasChildNodes()).toBe(false);

        expect(node.isEqualNode(node)).toBe(true);
        expect(node.isEqualNode(p)).toBe(false);
        expect(node.isEqualNode(node.firstChild)).toBe(false);

        expect(node.compareDocumentPosition(node)).toBe(0);
github pugjs / react-jade / test / index.js View on Github external
test(name, function () {
    var src = fs.readFileSync(inputDir + '/' + name + '.jade', 'utf8');
    var expected = htmlparser.parseDOM(fs.readFileSync(inputDir + '/' + name + '.html', 'utf8'));
    fs.writeFileSync(outputDir + '/' + name + '.jade', src);
    var js = jade.compileFileClient(inputDir + '/' + name + '.jade', {
      outputFile: outputDir + '/' + name + '.js',
      basedir: inputDir
    });
    fs.writeFileSync(outputDir + '/' + name + '.js', js);
    mockDom.mock();
    var fn = jade.compileFile(inputDir + '/' + name + '.jade', {
      outputFile: outputDir + '/' + name + '.js',
      basedir: inputDir
    });
    var actual = fn({title: 'Jade'});
    var hasDiv = expected.filter(function(element) { return element.type !== 'text' }).length !== 1;
    actual = hasDiv ? actual.children : actual;
    mockDom.reset();
github fb55 / css-select / test / tools / helper.js View on Github external
function getDOMFromPath(path, options) {
    return htmlparser2.parseDOM(fs.readFileSync(path).toString(), options);
}
github disqus / grunt-smartrev / lib / handlers / html.js View on Github external
const extract = function () {
    this.ast = htmlparser.parseDOM(fs.readFileSync(this.name).toString());

    domutils.findAll(shouldModify, this.ast).forEach(parseElem, this);

    return this;
};
github realywithoutname / mini-program-webpack-loader / src / helpers / wxml-parser.js View on Github external
module.exports.find = function find (content, test) {
  let dom = parseDOM(content, {
    recognizeSelfClosing: true,
    lowerCaseAttributeNames: false
  })
  DomUtils.find(test, dom, true)
  return dom
}