Skip to content

Commit

Permalink
feat: remove static text parse mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Feb 16, 2022
1 parent 5f28e23 commit d0a5e5d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 83 deletions.
40 changes: 5 additions & 35 deletions src/core/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down Expand Up @@ -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
Expand Down
46 changes: 0 additions & 46 deletions src/states/STATIC_TEXT_CONTENT.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/states/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 0 additions & 1 deletion src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit d0a5e5d

Please sign in to comment.