How to use the parse5.SimpleApiParser function in parse5

To help you get started, we’ve selected a few parse5 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 stevenvachon / broken-link-checker / lib / internal / HtmlLinkParser.js View on Github external
this.parserVars = 
	{
		// Parse session variables
		elementStack: [],
		htmlBase: {},
		linkCount: 0,
		linkElementStack: [],
		
		// Per-link variables
		links: [],
		selector: "",
		voidElement: false
	};
	
	this.parser = new parse5.SimpleApiParser(
	{
		startTag: function(tagName, attrs, selfClosing)
		{
			handler_startTag(thisObj, tagName, attrs, selfClosing);
		},
		endTag: function(tagName)
		{
			handler_endTag(thisObj, tagName);
		},
		text: function(text)
		{
			handler_text(thisObj, text);
		}
	});
}
github vernonk / patternguide / patternguide / node / core / comment-parser.js View on Github external
function htmlParser ( str, filepath ) {
  var comments = [],
      parse5Parser = new parse5.SimpleApiParser({
        comment: function ( str ) {
          comments.push( translator.translate( str ) );
        }
      });
  // send our view through the parser
  parse5Parser.parse( str );
  return { err: null, data: { comments: comments } };
}
github bem / html-differ / lib / utils / modify.js View on Github external
function modify(value, options) {
    var modifiedValue = '',
        parser;

    parser = new SimpleApiParser({
        /**
         * @param {String} name
         * @param {String} publicId
         * @param {String} systemId
         */
        doctype: function (name, publicId, systemId) {
            modifiedValue += serialize.doctype(name, publicId, systemId);
        },
        /**
         * @param {String} tagName
         * @param {Array} attrs
         * @param {Boolean} selfClosing
         */
        startTag: function (tagName, attrs, selfClosing) {
            if (options.ignoreDuplicateAttributes) {
                attrs = utils.removeDuplicateAttributes(attrs);
github icons8 / impresser-html-angular-minifier / lib / Compressor.js View on Github external
apply: function(content) {
    var
      parser,
      output = '';

    parser = new parse5.SimpleApiParser({

      doctype: function(name, publicId, systemId) {
        var
          doctype;

        doctype = '';

        output += doctype;
      },

      startTag: function(tag, attrs, unary) {
github inikulin / ineed / lib / pipeline.js View on Github external
var Pipeline = module.exports = function () {
    this.plugins = [ContextPlugin];
    this.pluginInitArgs = {};

    var pipeline = this;

    //NOTE: we don't use .bind() here because it uses quite slow .apply() internally.
    this.parser = new parse5.SimpleApiParser({
        doctype: function (name, publicId, systemId) {
            pipeline.onDoctype({
                name: name,
                publicId: publicId,
                systemId: systemId
            });
        },

        startTag: function (tagName, attrs, selfClosing) {
            pipeline.onStartTag({
                tagName: tagName,
                attrs: attrs,
                selfClosing: selfClosing
            });
        },
github inikulin / ineed / lib / iwant.js View on Github external
var Scraper = function () {
    this.extractors = [];
    this.charsetEncoding = null;
    this.baseTagFound = false;

    this.commonState = {
        baseUrl: null,
        inElement: null,
        inBody: false
    };

    var scrapper = this;

    //NOTE: we don't use bind() here because it uses quite slow .apply() internally.
    this.parser = new parse5.SimpleApiParser({
        doctype: function (name, publicId, systemId) {
            scrapper._onDoctype(name, publicId, systemId);
        },

        startTag: function (tagName, attrs, selfClosing) {
            scrapper._onStartTag(tagName, attrs, selfClosing);
        },

        endTag: function (tagName) {
            scrapper._onEndTag(tagName);
        },

        text: function (text) {
            scrapper._onText(text);
        },