"use strict";
// /*
// * Modified version of htmlparser2 which has been stripped down to only provide
// * the functionality needed by Autolinker in order to make the final bundle as
// * small as possible.
// *
// * See license in tokenizer.ts
// */
// import { tokenizeHtml } from './tokenizer';
// export function parseHtml( html: string, {
// } ) {
// /*
// Callbacks:
// oncdataend,
// oncdatastart,
// onclosetag,
// oncomment,
// oncommentend,
// onerror,
// onopentag,
// onprocessinginstruction,
// onreset,
// ontext
// */
// var formTags = {
// input: true,
// option: true,
// optgroup: true,
// select: true,
// button: true,
// datalist: true,
// textarea: true
// };
// var openImpliesClose = {
// tr: { tr: true, th: true, td: true },
// th: { th: true },
// td: { thead: true, th: true, td: true },
// body: { head: true, link: true, script: true },
// li: { li: true },
// p: { p: true },
// h1: { p: true },
// h2: { p: true },
// h3: { p: true },
// h4: { p: true },
// h5: { p: true },
// h6: { p: true },
// select: formTags,
// input: formTags,
// output: formTags,
// button: formTags,
// datalist: formTags,
// textarea: formTags,
// option: { option: true },
// optgroup: { optgroup: true }
// };
// var voidElements = {
// __proto__: null,
// area: true,
// base: true,
// basefont: true,
// br: true,
// col: true,
// command: true,
// embed: true,
// frame: true,
// hr: true,
// img: true,
// input: true,
// isindex: true,
// keygen: true,
// link: true,
// meta: true,
// param: true,
// source: true,
// track: true,
// wbr: true
// };
// var foreignContextElements = {
// __proto__: null,
// math: true,
// svg: true
// };
// var htmlIntegrationElements = {
// __proto__: null,
// mi: true,
// mo: true,
// mn: true,
// ms: true,
// mtext: true,
// "annotation-xml": true,
// foreignObject: true,
// desc: true,
// title: true
// };
// var re_nameEnd = /\s|\//;
// let _options = options || {};
// let _cbs = cbs || {};
// let _tagname = "";
// let _attribname = "";
// let _attribvalue = "";
// let _attribs = null;
// let _stack = [];
// let _foreignContext = [];
// let _lowerCaseTagNames =
// "lowerCaseTags" in _options
// ? !!_options.lowerCaseTags
// : !_options.xmlMode;
// let _lowerCaseAttributeNames =
// "lowerCaseAttributeNames" in _options
// ? !!_options.lowerCaseAttributeNames
// : !_options.xmlMode;
// tokenizeHtml( html, {
// ontext,
// onopentagname,
// onopentagend,
// onclosetag,
// onselfclosingtag,
// oncomment,
// onerror
// } );
// //Tokenizer event handlers
// function ontext(data) {
// if (_cbs.ontext) _cbs.ontext(data);
// };
// function onopentagname(name) {
// if (_lowerCaseTagNames) {
// name = name.toLowerCase();
// }
// _tagname = name;
// if (!_options.xmlMode && name in openImpliesClose) {
// for (
// var el;
// (el = _stack[_stack.length - 1]) in
// openImpliesClose[name];
// onclosetag(el)
// );
// }
// if (_options.xmlMode || !(name in voidElements)) {
// _stack.push(name);
// if (name in foreignContextElements) _foreignContext.push(true);
// else if (name in htmlIntegrationElements)
// _foreignContext.push(false);
// }
// if (_cbs.onopentagname) _cbs.onopentagname(name);
// if (_cbs.onopentag) _attribs = {};
// };
// function onopentagend() {
// if (_attribs) {
// if (_cbs.onopentag)
// _cbs.onopentag(_tagname, _attribs);
// _attribs = null;
// }
// if (
// !_options.xmlMode &&
// _cbs.onclosetag &&
// _tagname in voidElements
// ) {
// _cbs.onclosetag(_tagname);
// }
// _tagname = "";
// };
// function onclosetag(name) {
// _updatePosition(1);
// if (_lowerCaseTagNames) {
// name = name.toLowerCase();
// }
// if (
// _stack.length &&
// (!(name in voidElements) || _options.xmlMode)
// ) {
// var pos = _stack.lastIndexOf(name);
// if (pos !== -1) {
// if (_cbs.onclosetag) {
// pos = _stack.length - pos;
// while (pos--) _cbs.onclosetag(_stack.pop());
// } else _stack.length = pos;
// } else if (name === "p" && !_options.xmlMode) {
// onopentagname(name);
// _closeCurrentTag();
// }
// } else if (!_options.xmlMode && (name === "br" || name === "p")) {
// onopentagname(name);
// _closeCurrentTag();
// }
// };
// function onselfclosingtag() {
// if (
// _options.xmlMode ||
// _options.recognizeSelfClosing ||
// _foreignContext[_foreignContext.length - 1]
// ) {
// _closeCurrentTag();
// } else {
// onopentagend();
// }
// };
// function _closeCurrentTag() {
// var name = _tagname;
// onopentagend();
// //self-closing tags will be on the top of the stack
// //(cheaper check than in onclosetag)
// if (_stack[_stack.length - 1] === name) {
// if (_cbs.onclosetag) {
// _cbs.onclosetag(name);
// }
// _stack.pop();
// if (name in foreignContextElements || name in htmlIntegrationElements) {
// _foreignContext.pop();
// }
// }
// };
// function onattribname(name) {
// if (_lowerCaseAttributeNames) {
// name = name.toLowerCase();
// }
// _attribname = name;
// };
// function onattribdata(value) {
// _attribvalue += value;
// };
// function onattribend() {
// if (_cbs.onattribute)
// _cbs.onattribute(_attribname, _attribvalue);
// if (
// _attribs &&
// !Object.prototype.hasOwnProperty.call(_attribs, _attribname)
// ) {
// _attribs[_attribname] = _attribvalue;
// }
// _attribname = "";
// _attribvalue = "";
// };
// function _getInstructionName(value) {
// var idx = value.search(re_nameEnd),
// name = idx < 0 ? value : value.substr(0, idx);
// if (_lowerCaseTagNames) {
// name = name.toLowerCase();
// }
// return name;
// };
// function ondeclaration(value) {
// if (_cbs.onprocessinginstruction) {
// var name = _getInstructionName(value);
// _cbs.onprocessinginstruction("!" + name, "!" + value);
// }
// };
// function onprocessinginstruction(value) {
// if (_cbs.onprocessinginstruction) {
// var name = _getInstructionName(value);
// _cbs.onprocessinginstruction("?" + name, "?" + value);
// }
// };
// function oncomment(value) {
// _updatePosition(4);
// if (_cbs.oncomment) _cbs.oncomment(value);
// if (_cbs.oncommentend) _cbs.oncommentend();
// };
// function oncdata(value) {
// _updatePosition(1);
// if (_options.xmlMode || _options.recognizeCDATA) {
// if (_cbs.oncdatastart) _cbs.oncdatastart();
// if (_cbs.ontext) _cbs.ontext(value);
// if (_cbs.oncdataend) _cbs.oncdataend();
// } else {
// oncomment("[CDATA[" + value + "]]");
// }
// };
// function onerror(err) {
// if (_cbs.onerror) _cbs.onerror(err);
// };
// function onend() {
// if (_cbs.onclosetag) {
// for (
// var i = _stack.length;
// i > 0;
// _cbs.onclosetag(_stack[--i])
// );
// }
// if (_cbs.onend) _cbs.onend();
// };
// }
//# sourceMappingURL=parser-old.js.map