How to use parse5-sax-parser - 1 common examples

To help you get started, we’ve selected a few parse5-sax-parser 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 popcodeorg / popcode / src / validations / html / runRules.js View on Github external
export default (rules, source) => {
  const parser = new SAXParser({sourceCodeLocationInfo: true});
  return new Promise(resolve => {
    parser.on(
      'startTag',
      ({tagName, selfClosing, sourceCodeLocation: {startLine, startCol}}) => {
        for (const rule of rules) {
          if (rule.openTag && !selfClosing && !(tagName in voidElements)) {
            rule.openTag(
              {row: startLine - 1, column: startCol - 1},
              {name: tagName},
            );
          }
        }
      },
    );
    parser.on(
      'endTag',

parse5-sax-parser

Streaming SAX-style HTML parser.

MIT
Latest version published 3 years ago

Package Health Score

84 / 100
Full package analysis

Popular parse5-sax-parser functions