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yBAAyB;QACjC,OAAO,EAAE,CAAC;IACX,CAAC;AACF,CAAC;AAGD;IAOC,oBAAa,GAA6B;QAA7B,oBAAA,EAAA,QAA6B;QACzC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;IAClC,CAAC;IACF,iBAAC;AAAD,CAdA,AAcC,IAAA","file":"parse-html.js","sourcesContent":["import { State } from './state';\nimport { letterRe, digitRe, whitespaceRe, quoteRe, controlCharsRe } from '../regex-lib';\nimport { throwUnhandledCaseError } from '../utils';\n\n// For debugging: search for other \"For debugging\" lines\n// import CliTable from 'cli-table';\n\n/**\n * Parses an HTML string, calling the callbacks to notify of tags and text.\n *\n * ## History\n * \n * This file previously used a regular expression to find html tags in the input \n * text. Unfortunately, we ran into a bunch of catastrophic backtracking issues \n * with certain input text, causing Autolinker to either hang or just take a \n * really long time to parse the string.\n *\n * The current code is intended to be a O(n) algorithm that walks through\n * the string in one pass, and tries to be as cheap as possible. We don't need\n * to implement the full HTML spec, but rather simply determine where the string\n * looks like an HTML tag, and where it looks like text (so that we can autolink\n * that).\n * \n * This state machine parser is intended just to be a simple but performant\n * parser of HTML for the subset of requirements we have. We simply need to:\n *\n * 1. Determine where HTML tags are\n * 2. Determine the tag name (Autolinker specifically only cares about <a>,\n * <script>, and <style> tags, so as not to link any text within them)\n *\n * We don't need to:\n *\n * 1. Create a parse tree\n * 2. Auto-close tags with invalid markup\n * 3. etc.\n * \n * The other intention behind this is that we didn't want to add external \n * dependencies on the Autolinker utility which would increase its size. For \n * instance, adding htmlparser2 adds 125kb to the minified output file,\n * increasing its final size from 47kb to 172kb (at the time of writing). It \n * also doesn't work exactly correctly, treating the string \"<3 blah blah blah\"\n * as an HTML tag.\n * \n * Reference for HTML spec: \n * \n * https://www.w3.org/TR/html51/syntax.html#sec-tokenization\n *\n * @param {String} html The HTML to parse\n * @param {Object} callbacks\n * @param {Function} callbacks.onOpenTag Callback function to call when an open\n * tag is parsed. Called with the tagName as its argument.\n * @param {Function} callbacks.onCloseTag Callback function to call when a close\n * tag is parsed. Called with the tagName as its argument. If a self-closing\n * tag is found, `onCloseTag` is called immediately after `onOpenTag`.\n * @param {Function} callbacks.onText Callback function to call when text (i.e\n * not an HTML tag) is parsed. Called with the text (string) as its first \n * argument, and offset (number) into the string as its second.\n */\nexport function parseHtml( html: string, { onOpenTag, onCloseTag, onText, onComment, onDoctype }: {\n\tonOpenTag: ( tagName: string, offset: number ) => void;\n\tonCloseTag: ( tagName: string, offset: number ) => void;\n\tonText: ( text: string, offset: number ) => void;\n\tonComment: ( offset: number ) => void;\n\tonDoctype: ( offset: number ) => void;\n} ) {\n\tconst noCurrentTag = new CurrentTag();\n\n\tlet charIdx = 0,\n\t\tlen = html.length,\n\t\tstate = State.Data as State,\n\n\t\tcurrentDataIdx = 0, // where the current data start index is\n\t\tcurrentTag = noCurrentTag; // describes the current tag that is being read\n\n\t// For debugging: search for other \"For debugging\" lines\n\t// const table = new CliTable( {\n\t// \thead: [ 'charIdx', 'char', 'state', 'currentDataIdx', 'currentOpenTagIdx', 'tag.type' ]\n\t// } );\n\n\twhile( charIdx < len ) {\n\t\tvar char = html.charAt( charIdx );\n\n\t\t// For debugging: search for other \"For debugging\" lines\n\t\t// ALSO: Temporarily remove the 'const' keyword on the State enum\n\t\t// table.push( \n\t\t// \t[ charIdx, char, State[ state ], currentDataIdx, currentTag.idx, currentTag.idx === -1 ? '' : currentTag.type ] \n\t\t// );\n\t\t\n\t\tswitch( state ) {\n\t\t\tcase State.Data: stateData( char ); break;\n\t\t\tcase State.TagOpen: stateTagOpen( char ); break;\n\t\t\tcase State.EndTagOpen: stateEndTagOpen( char ); break;\n\t\t\tcase State.TagName: stateTagName( char ); break;\n\t\t\tcase State.BeforeAttributeName: stateBeforeAttributeName( char ); break;\n\t\t\tcase State.AttributeName: stateAttributeName( char ); break;\n\t\t\tcase State.AfterAttributeName: stateAfterAttributeName( char ); break;\n\t\t\tcase State.BeforeAttributeValue: stateBeforeAttributeValue( char ); break;\n\t\t\tcase State.AttributeValueDoubleQuoted: stateAttributeValueDoubleQuoted( char ); break;\n\t\t\tcase State.AttributeValueSingleQuoted: stateAttributeValueSingleQuoted( char ); break;\n\t\t\tcase State.AttributeValueUnquoted: stateAttributeValueUnquoted( char ); break;\n\t\t\tcase State.AfterAttributeValueQuoted: stateAfterAttributeValueQuoted( char ); break;\n\t\t\tcase State.SelfClosingStartTag: stateSelfClosingStartTag( char ); break;\n\t\t\tcase State.MarkupDeclarationOpenState: stateMarkupDeclarationOpen( char ); break;\n\t\t\tcase State.CommentStart: stateCommentStart( char ); break;\n\t\t\tcase State.CommentStartDash: stateCommentStartDash( char ); break;\n\t\t\tcase State.Comment: stateComment( char ); break;\n\t\t\tcase State.CommentEndDash: stateCommentEndDash( char ); break;\n\t\t\tcase State.CommentEnd: stateCommentEnd( char ); break;\n\t\t\tcase State.CommentEndBang: stateCommentEndBang( char ); break;\n\t\t\tcase State.Doctype: stateDoctype( char ); break;\n\n\t\t\tdefault: \n\t\t\t\tthrowUnhandledCaseError( state );\n\t\t}\n\n\t\t// For debugging: search for other \"For debugging\" lines\n\t\t// ALSO: Temporarily remove the 'const' keyword on the State enum\n\t\t// table.push( \n\t\t// \t[ charIdx, char, State[ state ], currentDataIdx, currentTag.idx, currentTag.idx === -1 ? '' : currentTag.type ] \n\t\t// );\n\n\t\tcharIdx++;\n\t}\n\n\tif( currentDataIdx < charIdx ) {\n\t\temitText();\n\t}\n\n\t// For debugging: search for other \"For debugging\" lines\n\t// console.log( '\\n' + table.toString() );\n\n\n\n\t// Called when non-tags are being read (i.e. the text around HTML †ags)\n\t// https://www.w3.org/TR/html51/syntax.html#data-state\n\tfunction stateData( char: string ) {\n\t\tif( char === '<' ) {\n\t\t\tstartNewTag();\n\t\t}\n\t}\n\n\t// Called after a '<' is read from the Data state\n\t// https://www.w3.org/TR/html51/syntax.html#tag-open-state\n\tfunction stateTagOpen( char: string ) {\n\t\tif( char === '!' ) {\n\t\t\tstate = State.MarkupDeclarationOpenState;\n\n\t\t} else if( char === '/' ) {\n\t\t\tstate = State.EndTagOpen;\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, isClosing: true } );\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else if( letterRe.test( char ) ) {\n\t\t\t// tag name start (and no '/' read)\n\t\t\tstate = State.TagName;\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, isOpening: true } );\n\n\t\t} else {\n\t\t\t// Any other \n\t\t\tstate = State.Data;\n\t\t\tcurrentTag = noCurrentTag;\n\t\t}\n\t}\n\n\t// After a '<x', '</x' sequence is read (where 'x' is a letter character), \n\t// this is to continue reading the tag name\n\t// https://www.w3.org/TR/html51/syntax.html#tag-name-state\n\tfunction stateTagName( char: string ) {\n\t\tif( whitespaceRe.test( char ) ) {\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, name: captureTagName() } );\n\t\t\tstate = State.BeforeAttributeName;\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else if( char === '/' ) {\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, name: captureTagName() } );\n\t\t\tstate = State.SelfClosingStartTag;\n\n\t\t} else if( char === '>' ) {\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, name: captureTagName() } );\n\t\t\temitTagAndPreviousTextNode(); // resets to Data state as well\n\n\t\t} else if( !letterRe.test( char ) && !digitRe.test( char ) && char !== ':' ) {\n\t\t\t// Anything else that does not form an html tag. Note: the colon \n\t\t\t// character is accepted for XML namespaced tags\n\t\t\tresetToDataState();\n\n\t\t} else {\n\t\t\t// continue reading tag name\n\t\t}\n\t}\n\n\t// Called after the '/' is read from a '</' sequence\n\t// https://www.w3.org/TR/html51/syntax.html#end-tag-open-state\n\tfunction stateEndTagOpen( char: string ) {\n\t\tif( char === '>' ) { // parse error. Encountered \"</>\". Skip it without treating as a tag\n\t\t\tresetToDataState();\n\t\t} else if( letterRe.test( char ) ) {\n\t\t\tstate = State.TagName;\n\t\t} else {\n\t\t\t// some other non-tag-like character, don't treat this as a tag\n\t\t\tresetToDataState();\n\t\t}\n\t}\n\t\n\n\t// https://www.w3.org/TR/html51/syntax.html#before-attribute-name-state\n\tfunction stateBeforeAttributeName( char: string ) {\n\t\tif( whitespaceRe.test( char ) ) {\n\t\t\t// stay in BeforeAttributeName state - continue reading chars\n\n\t\t} else if( char === '/' ) {\n\t\t\tstate = State.SelfClosingStartTag;\n\n\t\t} else if( char === '>' ) {\n\t\t\temitTagAndPreviousTextNode(); // resets to Data state as well\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else if( char === `=` || quoteRe.test( char ) || controlCharsRe.test( char ) ) {\n\t\t\t// \"Parse error\" characters that, according to the spec, should be\n\t\t\t// appended to the attribute name, but we'll treat these characters\n\t\t\t// as not forming a real HTML tag\n\t\t\tresetToDataState();\n\n\t\t} else {\n\t\t\t// Any other char, start of a new attribute name\n\t\t\tstate = State.AttributeName;\n\t\t}\n\t}\n\n\n\t// https://www.w3.org/TR/html51/syntax.html#attribute-name-state\n\tfunction stateAttributeName( char: string ) {\n\t\tif( whitespaceRe.test( char ) ) {\n\t\t\tstate = State.AfterAttributeName;\n\n\t\t} else if( char === '/' ) {\n\t\t\tstate = State.SelfClosingStartTag;\n\n\t\t} else if( char === '=' ) {\n\t\t\tstate = State.BeforeAttributeValue;\n\n\t\t} else if( char === '>' ) {\n\t\t\temitTagAndPreviousTextNode(); // resets to Data state as well\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else if( quoteRe.test( char ) ) {\n\t\t\t// \"Parse error\" characters that, according to the spec, should be\n\t\t\t// appended to the attribute name, but we'll treat these characters\n\t\t\t// as not forming a real HTML tag\n\t\t\tresetToDataState();\n\n\t\t} else {\n\t\t\t// anything else: continue reading attribute name\n\t\t}\n\t}\n\n\n\t// https://www.w3.org/TR/html51/syntax.html#after-attribute-name-state\n\tfunction stateAfterAttributeName( char: string ) {\n\t\tif( whitespaceRe.test( char ) ) {\n\t\t\t// ignore the character - continue reading\n\n\t\t} else if( char === '/' ) {\n\t\t\tstate = State.SelfClosingStartTag;\n\n\t\t} else if( char === '=' ) {\n\t\t\tstate = State.BeforeAttributeValue;\n\n\t\t} else if( char === '>' ) {\n\t\t\temitTagAndPreviousTextNode();\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else if( quoteRe.test( char ) ) {\n\t\t\t// \"Parse error\" characters that, according to the spec, should be\n\t\t\t// appended to the attribute name, but we'll treat these characters\n\t\t\t// as not forming a real HTML tag\n\t\t\tresetToDataState();\n\n\t\t} else {\n\t\t\t// Any other character, start a new attribute in the current tag\n\t\t\tstate = State.AttributeName;\n\t\t}\n\t}\n\n\n\t// https://www.w3.org/TR/html51/syntax.html#before-attribute-value-state\n\tfunction stateBeforeAttributeValue( char: string ) {\n\t\tif( whitespaceRe.test( char ) ) {\n\t\t\t// ignore the character - continue reading\n\n\t\t} else if( char === `\"` ) {\n\t\t\tstate = State.AttributeValueDoubleQuoted;\n\n\t\t} else if( char === `'` ) {\n\t\t\tstate = State.AttributeValueSingleQuoted;\n\n\t\t} else if( /[>=`]/.test( char ) ) {\n\t\t\t// Invalid chars after an '=' for an attribute value, don't count \n\t\t\t// the current tag as an HTML tag\n\t\t\tresetToDataState();\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else {\n\t\t\t// Any other character, consider it an unquoted attribute value\n\t\t\tstate = State.AttributeValueUnquoted;\n\t\t}\n\t}\n\n\n\t// https://www.w3.org/TR/html51/syntax.html#attribute-value-double-quoted-state\n\tfunction stateAttributeValueDoubleQuoted( char: string ) {\n\t\tif( char === `\"` ) { // end the current double-quoted attribute\n\t\t\tstate = State.AfterAttributeValueQuoted;\n\n\t\t} else {\n\t\t\t// consume the character as part of the double-quoted attribute value\n\t\t}\n\t}\n\n\n\t// https://www.w3.org/TR/html51/syntax.html#attribute-value-single-quoted-state\n\tfunction stateAttributeValueSingleQuoted( char: string ) {\n\t\tif( char === `'` ) { // end the current single-quoted attribute\n\t\t\tstate = State.AfterAttributeValueQuoted;\n\n\t\t} else {\n\t\t\t// consume the character as part of the double-quoted attribute value\n\t\t}\n\t}\n\n\n\t// https://www.w3.org/TR/html51/syntax.html#attribute-value-unquoted-state\n\tfunction stateAttributeValueUnquoted( char: string ) {\n\t\tif( whitespaceRe.test( char ) ) {\n\t\t\tstate = State.BeforeAttributeName;\n\n\t\t} else if( char === '>' ) {\n\t\t\temitTagAndPreviousTextNode();\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else {\n\t\t\t// Any other character, treat it as part of the attribute value\n\t\t}\n\t}\n\n\n\t// https://www.w3.org/TR/html51/syntax.html#after-attribute-value-quoted-state\n\tfunction stateAfterAttributeValueQuoted( char: string ) {\n\t\tif( whitespaceRe.test( char ) ) {\n\t\t\tstate = State.BeforeAttributeName;\n\n\t\t} else if( char === '/' ) {\n\t\t\tstate = State.SelfClosingStartTag;\n\n\t\t} else if( char === '>' ) {\n\t\t\temitTagAndPreviousTextNode();\n\n\t\t} else if( char === '<' ) {\n\t\t\t// start of another tag (ignore the previous, incomplete one)\n\t\t\tstartNewTag();\n\n\t\t} else {\n\t\t\t// Any other character, \"parse error\". Spec says to switch to the\n\t\t\t// BeforeAttributeState and re-consume the character, as it may be\n\t\t\t// the start of a new attribute name\n\t\t\tstate = State.BeforeAttributeName;\n\t\t\treconsumeCurrentCharacter();\n\t\t}\n\t}\n\n\n\t// A '/' has just been read in the current tag (presumably for '/>'), and \n\t// this handles the next character\n\t// https://www.w3.org/TR/html51/syntax.html#self-closing-start-tag-state\n\tfunction stateSelfClosingStartTag( char: string ) {\n\t\tif( char === '>' ) {\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, isClosing: true } );\n\t\t\temitTagAndPreviousTextNode(); // resets to Data state as well\n\t\t\t\n\t\t} else {\n\t\t\tstate = State.BeforeAttributeName;\n\t\t}\n\t}\n\n\t// https://www.w3.org/TR/html51/syntax.html#markup-declaration-open-state\n\t// (HTML Comments or !DOCTYPE)\n\tfunction stateMarkupDeclarationOpen( char: string ) {\n\t\tif( html.substr( charIdx, 2 ) === '--' ) { // html comment\n\t\t\tcharIdx += 2; // \"consume\" characters\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, type: 'comment' } );\n\t\t\tstate = State.CommentStart;\n\n\t\t} else if( html.substr( charIdx, 7 ).toUpperCase() === 'DOCTYPE' ) {\n\t\t\tcharIdx += 7; // \"consume\" characters\n\t\t\tcurrentTag = new CurrentTag( { ...currentTag, type: 'doctype' } );\n\t\t\tstate = State.Doctype;\n\n\t\t} else {\n\t\t\t// At this point, the spec specifies that the state machine should\n\t\t\t// enter the \"bogus comment\" state, in which case any character(s) \n\t\t\t// after the '<!' that were read should become an HTML comment up\n\t\t\t// until the first '>' that is read (or EOF). Instead, we'll assume\n\t\t\t// that a user just typed '<!' as part of text data\n\t\t\tresetToDataState();\n\t\t}\n\t}\n\n\n\t// Handles after the sequence '<!--' has been read\n\t// https://www.w3.org/TR/html51/syntax.html#comment-start-state\n\tfunction stateCommentStart( char: string ) {\n\t\tif( char === '-' ) {\n\t\t\t// We've read the sequence '<!---' at this point (3 dashes)\n\t\t\tstate = State.CommentStartDash;\n\n\t\t} else if( char === '>' ) {\n\t\t\t// At this point, we'll assume the comment wasn't a real comment\n\t\t\t// so we'll just emit it as data. We basically read the sequence \n\t\t\t// '<!-->'\n\t\t\tresetToDataState();\n\n\t\t} else {\n\t\t\t// Any other char, take it as part of the comment\n\t\t\tstate = State.Comment;\n\t\t}\n\t}\n\n\n\t// We've read the sequence '<!---' at this point (3 dashes)\n\t// https://www.w3.org/TR/html51/syntax.html#comment-start-dash-state\n\tfunction stateCommentStartDash( char: string ) {\n\t\tif( char === '-' ) {\n\t\t\t// We've read '<!----' (4 dashes) at this point\n\t\t\tstate = State.CommentEnd;\n\t\t\n\t\t} else if( char === '>' ) {\n\t\t\t// At this point, we'll assume the comment wasn't a real comment\n\t\t\t// so we'll just emit it as data. We basically read the sequence \n\t\t\t// '<!--->'\n\t\t\tresetToDataState();\n\n\t\t} else {\n\t\t\t// Anything else, take it as a valid comment\n\t\t\tstate = State.Comment;\n\t\t}\n\t}\n\n\t// Currently reading the comment's text (data)\n\t// https://www.w3.org/TR/html51/syntax.html#comment-state\n\tfunction stateComment( char: string ) {\n\t\tif( char === '-' ) {\n\t\t\tstate = State.CommentEndDash;\n\t\t} else {\n\t\t\t// Any other character, stay in the Comment state\n\t\t}\n\t}\n\n\t// When we we've read the first dash inside a comment, it may signal the\n\t// end of the comment if we read another dash\n\t// https://www.w3.org/TR/html51/syntax.html#comment-end-dash-state\n\tfunction stateCommentEndDash( char: string ) {\n\t\tif( char === '-' ) {\n\t\t\tstate = State.CommentEnd;\n\t\t} else {\n\t\t\t// Wasn't a dash, must still be part of the comment\n\t\t\tstate = State.Comment;\n\t\t}\n\t}\n\n\n\t// After we've read two dashes inside a comment, it may signal the end of \n\t// the comment if we then read a '>' char\n\t// https://www.w3.org/TR/html51/syntax.html#comment-end-state\n\tfunction stateCommentEnd( char: string ) {\n\t\tif( char === '>' ) {\n\t\t\temitTagAndPreviousTextNode();\n\n\t\t} else if( char === '!' ) {\n\t\t\tstate = State.CommentEndBang;\n\n\t\t} else if( char === '-' ) {\n\t\t\t// A 3rd '-' has been read: stay in the CommentEnd state\n\n\t\t} else {\n\t\t\t// Anything else, switch back to the comment state since we didn't\n\t\t\t// read the full \"end comment\" sequence (i.e. '-->')\n\t\t\tstate = State.Comment;\n\t\t}\n\t}\n\n\t// We've read the sequence '--!' inside of a comment\n\t// https://www.w3.org/TR/html51/syntax.html#comment-end-bang-state\n\tfunction stateCommentEndBang( char: string ) {\n\t\tif( char === '-' ) {\n\t\t\t// We read the sequence '--!-' inside of a comment. The last dash\n\t\t\t// could signify that the comment is going to close\n\t\t\tstate = State.CommentEndDash;\n\n\t\t} else if( char === '>' ) {\n\t\t\t// End of comment with the sequence '--!>'\n\t\t\temitTagAndPreviousTextNode();\n\n\t\t} else {\n\t\t\t// The '--!' was not followed by a '>', continue reading the \n\t\t\t// comment's text\n\t\t\tstate = State.Comment;\n\t\t}\n\t}\n\n\n\t/**\n\t * For DOCTYPES in particular, we don't care about the attributes. Just \n\t * advance to the '>' character and emit the tag, unless we find a '<' \n\t * character in which case we'll start a new tag.\n\t * \n\t * Example doctype tag:\n\t * <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> \n\t * \n\t * Actual spec: https://www.w3.org/TR/html51/syntax.html#doctype-state\n\t */\n\tfunction stateDoctype( char: string ) {\n\t\tif( char === '>' ) {\n\t\t\temitTagAndPreviousTextNode();\n\n\t\t} else if( char === '<' ) {\n\t\t\tstartNewTag();\n\n\t\t} else {\n\t\t\t// stay in the Doctype state\n\t\t}\n\t}\n\n\n\t/**\n\t * Resets the state back to the Data state, and removes the current tag.\n\t * \n\t * We'll generally run this function whenever a \"parse error\" is \n\t * encountered, where the current tag that is being read no longer looks \n\t * like a real HTML tag.\n\t */\n\tfunction resetToDataState() {\n\t\tstate = State.Data;\n\t\tcurrentTag = noCurrentTag;\n\t}\n\n\n\t/**\n\t * Starts a new HTML tag at the current index, ignoring any previous HTML\n\t * tag that was being read.\n\t * \n\t * We'll generally run this function whenever we read a new '<' character,\n\t * including when we read a '<' character inside of an HTML tag that we were\n\t * previously reading.\n\t */\n\tfunction startNewTag() {\n\t\tstate = State.TagOpen;\n\t\tcurrentTag = new CurrentTag( { idx: charIdx } );\n\t}\n\n\t/**\n\t * Once we've decided to emit an open tag, that means we can also emit the\n\t * text node before it.\n\t */\n\tfunction emitTagAndPreviousTextNode() {\n\t\tconst textBeforeTag = html.slice( currentDataIdx, currentTag.idx );\n\t\tif( textBeforeTag ) {\n\t\t\t// the html tag was the first element in the html string, or two \n\t\t\t// tags next to each other, in which case we should not emit a text \n\t\t\t// node\n\t\t\tonText( textBeforeTag, currentDataIdx );\n\t\t}\n\n\t\tif( currentTag.type === 'comment' ) {\n\t\t\tonComment( currentTag.idx );\n\n\t\t} else if( currentTag.type === 'doctype' ) {\n\t\t\tonDoctype( currentTag.idx );\n\n\t\t} else {\n\t\t\tif( currentTag.isOpening ) {\n\t\t\t\tonOpenTag( currentTag.name, currentTag.idx );\n\t\t\t}\n\t\t\tif( currentTag.isClosing ) { // note: self-closing tags will emit both opening and closing\n\t\t\t\tonCloseTag( currentTag.name, currentTag.idx );\n\t\t\t}\n\t\t}\n\n\t\t// Since we just emitted a tag, reset to the data state for the next char\n\t\tresetToDataState();\n\t\tcurrentDataIdx = charIdx + 1;\n\t}\n\n\n\tfunction emitText() {\n\t\tconst text = html.slice( currentDataIdx, charIdx );\n\t\tonText( text, currentDataIdx );\n\n\t\tcurrentDataIdx = charIdx + 1;\n\t}\n\n\t/**\n\t * Captures the tag name from the start of the tag to the current character \n\t * index, and converts it to lower case\n\t */\n\tfunction captureTagName() {\n\t\tconst startIdx = currentTag.idx + ( currentTag.isClosing ? 2 : 1 );\n\t\treturn html.slice( startIdx, charIdx ).toLowerCase();\n\t}\n\n\n\t/**\n\t * Causes the main loop to re-consume the current character, such as after\n\t * encountering a \"parse error\" that changed state and needs to reconsume\n\t * the same character in that new state.\n\t */\n\tfunction reconsumeCurrentCharacter() {\n\t\tcharIdx--;\n\t}\n}\n\n\nclass CurrentTag {\n\treadonly idx: number; // the index of the '<' in the html string\n\treadonly type: 'tag' | 'comment' | 'doctype';\n\treadonly name: string;\n\treadonly isOpening: boolean; // true if it's an opening tag, OR a self-closing open tag\n\treadonly isClosing: boolean; // true if it's a closing tag, OR a self-closing open tag\n\n\tconstructor( cfg: Partial<CurrentTag> = {} ) {\n\t\tthis.idx = cfg.idx !== undefined ? cfg.idx : -1;\n\t\tthis.type = cfg.type || 'tag';\n\t\tthis.name = cfg.name || '';\n\t\tthis.isOpening = !!cfg.isOpening;\n\t\tthis.isClosing = !!cfg.isClosing;\n\t}\n}"]}