From 8ff1c682d30b00652bac4398901341e510609318 Mon Sep 17 00:00:00 2001 From: kotaindah55 Date: Mon, 3 Feb 2025 20:18:05 +0200 Subject: [PATCH] feat: enums giving additional informations to token --- src/enums/LineCtx.ts | 13 +++++++++++++ src/enums/TokenRole.ts | 19 +++++++++++++++++++ src/enums/TokenStatus.ts | 23 +++++++++++++++++++++++ src/enums/index.ts | 5 ++++- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/enums/LineCtx.ts create mode 100644 src/enums/TokenRole.ts create mode 100644 src/enums/TokenStatus.ts diff --git a/src/enums/LineCtx.ts b/src/enums/LineCtx.ts new file mode 100644 index 0000000..1fbbb1b --- /dev/null +++ b/src/enums/LineCtx.ts @@ -0,0 +1,13 @@ +export enum LineCtx { + NONE, + HR_LINE, + HEADING, + BLOCKQUOTE, + CODEBLOCK, + LIST_HEAD, + LIST, + FOOTNOTE_HEAD, + FOOTNOTE, + TABLE, + TABLE_DELIM +} \ No newline at end of file diff --git a/src/enums/TokenRole.ts b/src/enums/TokenRole.ts new file mode 100644 index 0000000..08c1cd2 --- /dev/null +++ b/src/enums/TokenRole.ts @@ -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 +} \ No newline at end of file diff --git a/src/enums/TokenStatus.ts b/src/enums/TokenStatus.ts new file mode 100644 index 0000000..34856fc --- /dev/null +++ b/src/enums/TokenStatus.ts @@ -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 +} \ No newline at end of file diff --git a/src/enums/index.ts b/src/enums/index.ts index ab1d2ac..ff3fb19 100644 --- a/src/enums/index.ts +++ b/src/enums/index.ts @@ -1 +1,4 @@ -export * from "./DelimType"; \ No newline at end of file +export * from "./LineCtx"; +export * from "./TokenRole"; +export * from "./TokenStatus"; +export * from "./Format"; \ No newline at end of file