'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var lr = require('@lezer/lr'); var highlight = require('@lezer/highlight'); var common = require('@lezer/common'); // This file was generated by lezer-generator. You probably shouldn't edit it. const scriptText = 54, StartCloseScriptTag = 1, styleText = 55, StartCloseStyleTag = 2, textareaText = 56, StartCloseTextareaTag = 3, EndTag = 4, SelfClosingEndTag = 5, StartTag = 6, StartScriptTag = 7, StartStyleTag = 8, StartTextareaTag = 9, StartSelfClosingTag = 10, StartCloseTag = 11, NoMatchStartCloseTag = 12, MismatchedStartCloseTag = 13, missingCloseTag = 57, IncompleteCloseTag = 14, commentContent$1 = 58, Element = 20, TagName = 22, Attribute = 23, AttributeName = 24, AttributeValue = 26, UnquotedAttributeValue = 27, ScriptText = 28, StyleText = 31, TextareaText = 34, OpenTag = 36, CloseTag = 37, Dialect_noMatch = 0, Dialect_selfClosing = 1; /* Hand-written tokenizers for HTML. */ const selfClosers = { area: true, base: true, br: true, col: true, command: true, embed: true, frame: true, hr: true, img: true, input: true, keygen: true, link: true, meta: true, param: true, source: true, track: true, wbr: true, menuitem: true }; const implicitlyClosed = { dd: true, li: true, optgroup: true, option: true, p: true, rp: true, rt: true, tbody: true, td: true, tfoot: true, th: true, tr: true }; const closeOnOpen = { dd: {dd: true, dt: true}, dt: {dd: true, dt: true}, li: {li: true}, option: {option: true, optgroup: true}, optgroup: {optgroup: true}, p: { address: true, article: true, aside: true, blockquote: true, dir: true, div: true, dl: true, fieldset: true, footer: true, form: true, h1: true, h2: true, h3: true, h4: true, h5: true, h6: true, header: true, hgroup: true, hr: true, menu: true, nav: true, ol: true, p: true, pre: true, section: true, table: true, ul: true }, rp: {rp: true, rt: true}, rt: {rp: true, rt: true}, tbody: {tbody: true, tfoot: true}, td: {td: true, th: true}, tfoot: {tbody: true}, th: {td: true, th: true}, thead: {tbody: true, tfoot: true}, tr: {tr: true} }; function nameChar(ch) { return ch == 45 || ch == 46 || ch == 58 || ch >= 65 && ch <= 90 || ch == 95 || ch >= 97 && ch <= 122 || ch >= 161 } function isSpace(ch) { return ch == 9 || ch == 10 || ch == 13 || ch == 32 } let cachedName = null, cachedInput = null, cachedPos = 0; function tagNameAfter(input, offset) { let pos = input.pos + offset; if (cachedPos == pos && cachedInput == input) return cachedName let next = input.peek(offset); while (isSpace(next)) next = input.peek(++offset); let name = ""; for (;;) { if (!nameChar(next)) break name += String.fromCharCode(next); next = input.peek(++offset); } // Undefined to signal there's a or -1 ? new ElementContext(tagNameAfter(input, 1) || "", context) : context }, reduce(context, term) { return term == Element && context ? context.parent : context }, reuse(context, node, stack, input) { let type = node.type.id; return type == StartTag || type == OpenTag ? new ElementContext(tagNameAfter(input, 1) || "", context) : context }, strict: false }); const tagStart = new lr.ExternalTokenizer((input, stack) => { if (input.next != lessThan) { // End of file, close any open tags if (input.next < 0 && stack.context) input.acceptToken(missingCloseTag); return } input.advance(); let close = input.next == slash; if (close) input.advance(); let name = tagNameAfter(input, 0); if (name === undefined) return if (!name) return input.acceptToken(close ? IncompleteCloseTag : StartTag) let parent = stack.context ? stack.context.name : null; if (close) { if (name == parent) return input.acceptToken(StartCloseTag) if (parent && implicitlyClosed[parent]) return input.acceptToken(missingCloseTag, -2) if (stack.dialectEnabled(Dialect_noMatch)) return input.acceptToken(NoMatchStartCloseTag) for (let cx = stack.context; cx; cx = cx.parent) if (cx.name == name) return input.acceptToken(MismatchedStartCloseTag); } else { if (name == "script") return input.acceptToken(StartScriptTag) if (name == "style") return input.acceptToken(StartStyleTag) if (name == "textarea") return input.acceptToken(StartTextareaTag) if (selfClosers.hasOwnProperty(name)) return input.acceptToken(StartSelfClosingTag) if (parent && closeOnOpen[parent] && closeOnOpen[parent][name]) input.acceptToken(missingCloseTag, -1); else input.acceptToken(StartTag); } }, {contextual: true}); const commentContent = new lr.ExternalTokenizer(input => { for (let dashes = 0, i = 0;; i++) { if (input.next < 0) { if (i) input.acceptToken(commentContent$1); break } if (input.next == dash) { dashes++; } else if (input.next == greaterThan && dashes >= 2) { if (i >= 3) input.acceptToken(commentContent$1, -2); break } else { dashes = 0; } input.advance(); } }); function inForeignElement(context) { for (; context; context = context.parent) if (context.name == "svg" || context.name == "math") return true return false } const endTag = new lr.ExternalTokenizer((input, stack) => { if (input.next == slash && input.peek(1) == greaterThan) { let selfClosing = stack.dialectEnabled(Dialect_selfClosing) || inForeignElement(stack.context); input.acceptToken(selfClosing ? SelfClosingEndTag : EndTag, 2); } else if (input.next == greaterThan) { input.acceptToken(EndTag, 1); } }); function contentTokenizer(tag, textToken, endToken) { let lastState = 2 + tag.length; return new lr.ExternalTokenizer(input => { // state means: // - 0 nothing matched // - 1 '<' matched // - 2 '' + possibly whitespace matched // - 3-(1+tag.length) part of the tag matched // - lastState whole tag + possibly whitespace matched for (let state = 0, matchedLen = 0, i = 0;; i++) { if (input.next < 0) { if (i) input.acceptToken(textToken); break } if (state == 0 && input.next == lessThan || state == 1 && input.next == slash || state >= 2 && state < lastState && input.next == tag.charCodeAt(state - 2)) { state++; matchedLen++; } else if ((state == 2 || state == lastState) && isSpace(input.next)) { matchedLen++; } else if (state == lastState && input.next == greaterThan) { if (i > matchedLen) input.acceptToken(textToken, -matchedLen); else input.acceptToken(endToken, -(matchedLen - 2)); break } else if ((input.next == 10 /* '\n' */ || input.next == 13 /* '\r' */) && i) { input.acceptToken(textToken, 1); break } else { state = matchedLen = 0; } input.advance(); } }) } const scriptTokens = contentTokenizer("script", scriptText, StartCloseScriptTag); const styleTokens = contentTokenizer("style", styleText, StartCloseStyleTag); const textareaTokens = contentTokenizer("textarea", textareaText, StartCloseTextareaTag); const htmlHighlighting = highlight.styleTags({ "Text RawText": highlight.tags.content, "StartTag StartCloseTag SelfClosingEndTag EndTag": highlight.tags.angleBracket, TagName: highlight.tags.tagName, "MismatchedCloseTag/TagName": [highlight.tags.tagName, highlight.tags.invalid], AttributeName: highlight.tags.attributeName, "AttributeValue UnquotedAttributeValue": highlight.tags.attributeValue, Is: highlight.tags.definitionOperator, "EntityReference CharacterReference": highlight.tags.character, Comment: highlight.tags.blockComment, ProcessingInst: highlight.tags.processingInstruction, DoctypeDecl: highlight.tags.documentMeta }); // This file was generated by lezer-generator. You probably shouldn't edit it. const parser = lr.LRParser.deserialize({ version: 14, states: ",xOVO!rOOO!WQ#tO'#CqO!]Q#tO'#CzO!bQ#tO'#C}O!gQ#tO'#DQO!lQ#tO'#DSO!qOaO'#CpO!|ObO'#CpO#XOdO'#CpO$eO!rO'#CpOOO`'#Cp'#CpO$lO$fO'#DTO$tQ#tO'#DVO$yQ#tO'#DWOOO`'#Dk'#DkOOO`'#DY'#DYQVO!rOOO%OQ&rO,59]O%ZQ&rO,59fO%fQ&rO,59iO%qQ&rO,59lO%|Q&rO,59nOOOa'#D^'#D^O&XOaO'#CxO&dOaO,59[OOOb'#D_'#D_O&lObO'#C{O&wObO,59[OOOd'#D`'#D`O'POdO'#DOO'[OdO,59[OOO`'#Da'#DaO'dO!rO,59[O'kQ#tO'#DROOO`,59[,59[OOOp'#Db'#DbO'pO$fO,59oOOO`,59o,59oO'xQ#|O,59qO'}Q#|O,59rOOO`-E7W-E7WO(SQ&rO'#CsOOQW'#DZ'#DZO(bQ&rO1G.wOOOa1G.w1G.wOOO`1G/Y1G/YO(mQ&rO1G/QOOOb1G/Q1G/QO(xQ&rO1G/TOOOd1G/T1G/TO)TQ&rO1G/WOOO`1G/W1G/WO)`Q&rO1G/YOOOa-E7[-E7[O)kQ#tO'#CyOOO`1G.v1G.vOOOb-E7]-E7]O)pQ#tO'#C|OOOd-E7^-E7^O)uQ#tO'#DPOOO`-E7_-E7_O)zQ#|O,59mOOOp-E7`-E7`OOO`1G/Z1G/ZOOO`1G/]1G/]OOO`1G/^1G/^O*PQ,UO,59_OOQW-E7X-E7XOOOa7+$c7+$cOOO`7+$t7+$tOOOb7+$l7+$lOOOd7+$o7+$oOOO`7+$r7+$rO*[Q#|O,59eO*aQ#|O,59hO*fQ#|O,59kOOO`1G/X1G/XO*kO7[O'#CvO*|OMhO'#CvOOQW1G.y1G.y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!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp", nodeNames: "⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl", maxTerm: 67, context: elementContext, nodeProps: [ ["closedBy", -10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,21,30,33,36,"CloseTag"], ["openedBy", 4,"StartTag StartCloseTag",5,"StartTag",-4,29,32,35,37,"OpenTag"], ["group", -9,14,17,18,19,20,39,40,41,42,"Entity",16,"Entity TextContent",-3,28,31,34,"TextContent Entity"], ["isolate", -11,21,29,30,32,33,35,36,37,38,41,42,"ltr",-3,26,27,39,""] ], propSources: [htmlHighlighting], skippedNodes: [0], repeatNodeCount: 9, tokenData: "!
]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zbkWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOa!R!R7tP;=`<%l7S!Z8OYkWa!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{ihSkWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbhSkWa!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!V