feat: enums giving additional informations to token

This commit is contained in:
kotaindah55 2025-02-03 20:18:05 +02:00
parent 683394f9a3
commit 8ff1c682d3
4 changed files with 59 additions and 1 deletions

13
src/enums/LineCtx.ts Normal file
View file

@ -0,0 +1,13 @@
export enum LineCtx {
NONE,
HR_LINE,
HEADING,
BLOCKQUOTE,
CODEBLOCK,
LIST_HEAD,
LIST,
FOOTNOTE_HEAD,
FOOTNOTE,
TABLE,
TABLE_DELIM
}

19
src/enums/TokenRole.ts Normal file
View file

@ -0,0 +1,19 @@
/**
* Indicate that the token is recognized as a part of
* tokens sequence, or a stand-alone one.
*/
export enum TokenRole {
/** Opening delimiter */
OPEN,
/**
* Act as a metadata stored in a token sequence.
* In this case, it's only used as a highlight color tag
*/
TAG,
/** Content of a token sequence */
CONTENT,
/** Closing delimiter */
CLOSE,
/** Stand-alone token that isn't a part of any sequence */
SINGLE
}

23
src/enums/TokenStatus.ts Normal file
View file

@ -0,0 +1,23 @@
/**
* To state whether the token is active or not.
* Only that stated as `ACTIVE` can pass through the
* rendering phase, whereas `INACTIVE` is used as a
* cut-through for reparsing when necessary.
* Note that, `INACTIVE` is only used by insertion,
* spoiler, sup, and sub.
*/
export enum TokenStatus {
/**
* The token is being processed through the parser queue.
* After that, its status switched to either `ACTIVE` or `INACTIVE`.
*/
PENDING,
/** The token is ready for the rendering phase. */
ACTIVE,
/**
* The token stated as `INACTIVE` by default doesn't
* go through rendering phase. Often used to stating
* token sequence that doesn't have closing delimiter.
*/
INACTIVE
}

View file

@ -1 +1,4 @@
export * from "./DelimType";
export * from "./LineCtx";
export * from "./TokenRole";
export * from "./TokenStatus";
export * from "./Format";