diff --git a/src/core/Parser.ts b/src/core/Parser.ts index 117e393a..0077dfd5 100644 --- a/src/core/Parser.ts +++ b/src/core/Parser.ts @@ -269,17 +269,11 @@ export class Parser { indent: this.indent, }); - switch (parent?.body) { - case BODY_MODE.PARSED_TEXT: - this.enterState(STATE.PARSED_TEXT_CONTENT); - break; - case BODY_MODE.STATIC_TEXT: - this.enterState(STATE.STATIC_TEXT_CONTENT); - break; - default: - this.enterState(STATE.HTML_CONTENT); - break; - } + this.enterState( + parent?.body === BODY_MODE.PARSED_TEXT + ? STATE.PARSED_TEXT_CONTENT + : STATE.HTML_CONTENT + ); } /** @@ -572,30 +566,6 @@ export class Parser { } } - enterStaticTextContentState() { - const last = - this.blockStack.length && this.blockStack[this.blockStack.length - 1]; - - if ( - !last || - last.type === "html" || - last.tagName.pos === last.tagName.endPos - ) { - throw new Error( - 'The "static text content" parser state is only allowed within a tag' - ); - } - - if (this.isConcise) { - // We will transition into the STATE.STATIC_TEXT_CONTENT state - // for each of the nested HTML blocks - last.body = BODY_MODE.STATIC_TEXT; - this.enterState(STATE.CONCISE_HTML_CONTENT); - } else { - this.enterState(STATE.STATIC_TEXT_CONTENT); - } - } - parse(data: string, filename: string) { // call the constructor function again because we have a contract that // it will fully reset the parser diff --git a/src/states/STATIC_TEXT_CONTENT.ts b/src/states/STATIC_TEXT_CONTENT.ts deleted file mode 100644 index c457af30..00000000 --- a/src/states/STATIC_TEXT_CONTENT.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { checkForClosingTag } from "."; -import { Parser, CODE, StateDefinition, isWhitespaceCode } from "../internal"; - -// We enter STATE.STATIC_TEXT_CONTENT when a listener manually chooses -// to enter this state after seeing an openTag event for a tag -// whose content should not be parsed at all (except for the purpose -// of looking for the end tag). -export const STATIC_TEXT_CONTENT: StateDefinition = { - name: "STATIC_TEXT_CONTENT", - - enter() { - this.textParseMode = "static-text"; - }, - - exit() { - this.endText(); - }, - - eol(newLine) { - if (this.isWithinSingleLineHtmlBlock) { - // We are parsing "HTML" and we reached the end of the line. If we are within a single - // line HTML block then we should return back to the state to parse concise HTML. - // A single line HTML block can be at the end of the tag or on its own line: - // - // span class="hello" - This is an HTML block at the end of a tag - // - This is an HTML block on its own line - // - this.endText(); - this.endHtmlBlock(); - } else if (this.htmlBlockDelimiter) { - this.handleDelimitedBlockEOL(newLine); - } - }, - - eof: Parser.prototype.htmlEOF, - - char(_, code) { - // See if we need to see if we reached the closing tag. - if ( - this.isConcise || - !(code === CODE.OPEN_ANGLE_BRACKET && checkForClosingTag(this)) - ) { - this.startText(); - } - }, -}; diff --git a/src/states/index.ts b/src/states/index.ts index db7a3b08..db5eb50f 100644 --- a/src/states/index.ts +++ b/src/states/index.ts @@ -14,7 +14,6 @@ export * from "./JS_COMMENT_LINE"; export * from "./PARSED_TEXT_CONTENT"; export * from "./PLACEHOLDER"; export * from "./REGULAR_EXPRESSION"; -export * from "./STATIC_TEXT_CONTENT"; export * from "./STRING"; export * from "./TAG_NAME"; export * from "./TEMPLATE_STRING"; diff --git a/src/util/constants.ts b/src/util/constants.ts index 982596f2..bf49906d 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -103,5 +103,4 @@ export enum MODE { export enum BODY_MODE { PARSED_TEXT = 1, // Body of a tag is treated as text, but placeholders will be parsed - STATIC_TEXT = 2, // Body of a tag is treated as text and placeholders will *not* be parsed }