diff options
author | bptato <nincsnevem662@gmail.com> | 2021-12-15 13:58:45 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-12-15 13:58:45 +0100 |
commit | 4360d3839bbb3303e82aabbe188805cb82c87eca (patch) | |
tree | 8091a9018f6985c356acfd246dc71629494f51c8 | |
parent | 7707d87c9a35a5915e59cfcbd21cd7c33f575a07 (diff) | |
download | chawan-4360d3839bbb3303e82aabbe188805cb82c87eca.tar.gz |
Refactor enums
-rw-r--r-- | src/css/parser.nim | 10 | ||||
-rw-r--r-- | src/css/selector.nim | 3 | ||||
-rw-r--r-- | src/css/style.nim | 2 | ||||
-rw-r--r-- | src/css/values.nim | 54 | ||||
-rw-r--r-- | src/html/dom.nim | 2 | ||||
-rw-r--r-- | src/html/parser.nim | 3 | ||||
-rw-r--r-- | src/html/tags.nim | 93 | ||||
-rw-r--r-- | src/io/buffer.nim | 2 | ||||
-rw-r--r-- | src/layout/box.nim | 1 | ||||
-rw-r--r-- | src/layout/engine.nim | 2 | ||||
-rw-r--r-- | src/types/enums.nim | 102 | ||||
-rw-r--r-- | src/types/tagtypes.nim | 51 |
12 files changed, 161 insertions, 164 deletions
diff --git a/src/css/parser.nim b/src/css/parser.nim index 0cfda3ed..2fdefef2 100644 --- a/src/css/parser.nim +++ b/src/css/parser.nim @@ -4,9 +4,17 @@ import options import sugar import utils/twtstr -import types/enums type + CSSTokenType* = enum + CSS_NO_TOKEN, CSS_IDENT_TOKEN, CSS_FUNCTION_TOKEN, CSS_AT_KEYWORD_TOKEN, + CSS_HASH_TOKEN, CSS_STRING_TOKEN, CSS_BAD_STRING_TOKEN, CSS_URL_TOKEN, + CSS_BAD_URL_TOKEN, CSS_DELIM_TOKEN, CSS_NUMBER_TOKEN, CSS_PERCENTAGE_TOKEN, + CSS_DIMENSION_TOKEN, CSS_WHITESPACE_TOKEN, CSS_CDO_TOKEN, CSS_CDC_TOKEN, + CSS_COLON_TOKEN, CSS_SEMICOLON_TOKEN, CSS_COMMA_TOKEN, CSS_RBRACKET_TOKEN, + CSS_LBRACKET_TOKEN, CSS_LPAREN_TOKEN, CSS_RPAREN_TOKEN, CSS_LBRACE_TOKEN, + CSS_RBRACE_TOKEN + CSSTokenizerState = object at: int stream: Stream diff --git a/src/css/selector.nim b/src/css/selector.nim index 13131f80..67f53b42 100644 --- a/src/css/selector.nim +++ b/src/css/selector.nim @@ -1,8 +1,7 @@ import unicode -import types/enums -import types/tagtypes import css/parser +import html/tags type SelectorType* = enum diff --git a/src/css/style.nim b/src/css/style.nim index 1b73fe71..172fc98c 100644 --- a/src/css/style.nim +++ b/src/css/style.nim @@ -10,7 +10,7 @@ import css/selector import css/parser import css/values import html/dom -import types/enums +import html/tags #TODO case sensitivity diff --git a/src/css/values.nim b/src/css/values.nim index 93dd3855..1dbe85a5 100644 --- a/src/css/values.nim +++ b/src/css/values.nim @@ -5,11 +5,62 @@ import sequtils import options import utils/twtstr -import types/enums import css/parser import types/color type + CSSUnit* = enum + UNIT_CM, UNIT_MM, UNIT_IN, UNIT_PX, UNIT_PT, UNIT_PC, + UNIT_EM, UNIT_EX, UNIT_CH, UNIT_REM, UNIT_VW, UNIT_VH, UNIT_VMIN, + UNIT_VMAX, UNIT_PERC, UNIT_IC + + CSSPropertyType* = enum + PROPERTY_NONE, PROPERTY_ALL, PROPERTY_COLOR, PROPERTY_MARGIN, + PROPERTY_MARGIN_TOP, PROPERTY_MARGIN_LEFT, PROPERTY_MARGIN_RIGHT, + PROPERTY_MARGIN_BOTTOM, PROPERTY_FONT_STYLE, PROPERTY_DISPLAY, + PROPERTY_CONTENT, PROPERTY_WHITE_SPACE, PROPERTY_FONT_WEIGHT, + PROPERTY_TEXT_DECORATION, PROPERTY_WORD_BREAK, PROPERTY_WIDTH, + PROPERTY_HEIGHT, PROPERTY_LIST_STYLE_TYPE + + CSSValueType* = enum + VALUE_NONE, VALUE_LENGTH, VALUE_COLOR, VALUE_CONTENT, VALUE_DISPLAY, + VALUE_FONT_STYLE, VALUE_WHITE_SPACE, VALUE_INTEGER, VALUE_TEXT_DECORATION, + VALUE_WORD_BREAK, VALUE_LIST_STYLE_TYPE + + CSSGlobalValueType* = enum + VALUE_NOGLOBAL, VALUE_INITIAL, VALUE_INHERIT, VALUE_REVERT, VALUE_UNSET + + CSSDisplay* = enum + DISPLAY_NONE, DISPLAY_INLINE, DISPLAY_BLOCK, DISPLAY_LIST_ITEM, + DISPLAY_INLINE_BLOCK, DISPLAY_TABLE, DISPLAY_TABLE_ROW_GROUP, + DISPLAY_TABLE_HEADER_GROUP, DISPLAY_TABLE_FOOTER_GROUP, + DISPLAY_TABLE_COLUMN_GROUP, DISPLAY_TABLE_ROW, DISPLAY_TABLE_COLUMN, + DISPLAY_TABLE_CELL + + CSSWhitespace* = enum + WHITESPACE_NORMAL, WHITESPACE_NOWRAP, WHITESPACE_PRE, WHITESPACE_PRE_LINE, + WHITESPACE_PRE_WRAP + + CSSFontStyle* = enum + FONTSTYLE_NORMAL, FONTSTYLE_ITALIC, FONTSTYLE_OBLIQUE + + CSSPosition* = enum + POSITION_STATIC, POSITION_RELATIVE, POSITION_ABSOLUTE, POSITION_FIXED, + POSITION_INHERIT + + CSSTextDecoration* = enum + TEXT_DECORATION_NONE, TEXT_DECORATION_UNDERLINE, TEXT_DECORATION_OVERLINE, + TEXT_DECORATION_LINE_THROUGH, TEXT_DECORATION_BLINK + + CSSWordBreak* = enum + WORD_BREAK_NORMAL, WORD_BREAK_BREAK_ALL, WORD_BREAK_KEEP_ALL + + CSSListStyleType* = enum + LIST_STYLE_TYPE_NONE, LIST_STYLE_TYPE_DISC, LIST_STYLE_TYPE_CIRCLE, + LIST_STYLE_TYPE_SQUARE, LIST_STYLE_TYPE_DECIMAL, + LIST_STYLE_TYPE_JAPANESE_INFORMAL + +type CSSLength* = object num*: float64 unit*: CSSUnit @@ -559,6 +610,7 @@ func cssListStyleType(d: CSSDeclaration): CSSListStyleType = of "circle": return LIST_STYLE_TYPE_CIRCLE of "square": return LIST_STYLE_TYPE_SQUARE of "decimal": return LIST_STYLE_TYPE_DECIMAL + of "roman": return LIST_STYLE_TYPE_DECIMAL of "japanese-informal": return LIST_STYLE_TYPE_JAPANESE_INFORMAL raise newException(CSSValueError, "Invalid list style") diff --git a/src/html/dom.nim b/src/html/dom.nim index 0c7d385a..7cb49f0e 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -4,7 +4,7 @@ import options import strutils import css/values -import types/enums +import html/tags type EventTarget* = ref EventTargetObj diff --git a/src/html/parser.nim b/src/html/parser.nim index 70b749a6..0e0fbaa0 100644 --- a/src/html/parser.nim +++ b/src/html/parser.nim @@ -5,12 +5,11 @@ import tables import json import options -import types/enums -import types/tagtypes import utils/twtstr import utils/radixtree import html/dom import html/entity +import html/tags type HTMLParseState = object diff --git a/src/html/tags.nim b/src/html/tags.nim new file mode 100644 index 00000000..4ffff21b --- /dev/null +++ b/src/html/tags.nim @@ -0,0 +1,93 @@ +import tables +import strutils + +type + NodeType* = enum + UNKNOWN_NODE = 0, + ELEMENT_NODE = 1, + ATTRIBUTE_NODE = 2, + TEXT_NODE = 3, + CDATA_SECTION_NODE = 4, + ENTITY_REFERENCE_NODE = 5, + ENTITY_NODE = 6 + PROCESSING_INSTRUCTION_NODE = 7, + COMMENT_NODE = 8, + DOCUMENT_NODE = 9, + DOCUMENT_TYPE_NODE = 10, + DOCUMENT_FRAGMENT_NODE = 11, + NOTATION_NODE = 12 + + InputType* = enum + INPUT_UNKNOWN, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_COLOR, INPUT_DATE, + INPUT_DATETIME_LOCAL, INPUT_EMAIL, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, + INPUT_MONTH, INPUT_NUMBER, INPUT_PASSWORD, INPUT_RADIO, INPUT_RANGE, + INPUT_RESET, INPUT_SEARCH, INPUT_SUBMIT, INPUT_TEL, INPUT_TEXT, INPUT_TIME, + INPUT_URL, INPUT_WEEK + + TagType* = enum + TAG_UNKNOWN, TAG_HTML, TAG_BASE, TAG_HEAD, TAG_LINK, TAG_META, TAG_STYLE, + TAG_TITLE, TAG_BODY, TAG_ADDRESS, TAG_ARTICLE, TAG_ASIDE, TAG_FOOTER, + TAG_HEADER, TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TAG_HGROUP, + TAG_MAIN, TAG_NAV, TAG_SECTION, TAG_BLOCKQUOTE, TAG_DD, TAG_DIV, TAG_DL, + TAG_DT, TAG_FIGCAPTION, TAG_FIGURE, TAG_HR, TAG_LI, TAG_OL, TAG_P, TAG_PRE, + TAG_UL, TAG_A, TAG_ABBR, TAG_B, TAG_BDI, TAG_BDO, TAG_BR, TAG_CITE, + TAG_CODE, TAG_DATA, TAG_DFN, TAG_EM, TAG_I, TAG_KBD, TAG_MARK, TAG_Q, + TAG_RB, TAG_RP, TAG_RT, TAG_RTC, TAG_RUBY, TAG_S, TAG_SAMP, TAG_SMALL, + TAG_SPAN, TAG_STRONG, TAG_SUB, TAG_SUP, TAG_TIME, TAG_U, TAG_VAR, TAG_WBR, + TAG_AREA, TAG_AUDIO, TAG_IMG, TAG_MAP, TAG_TRACK, TAG_VIDEO, + TAG_IFRAME, TAG_OBJECT, TAG_PARAM, TAG_PICTURE, TAG_PORTAL, TAG_SOURCE, + TAG_CANVAS, TAG_NOSCRIPT, TAG_SCRIPT, TAG_DEL, TAG_INS, TAG_CAPTION, + TAG_COL, TAG_COLGROUP, TAG_TABLE, TAG_TBODY, TAG_TD, TAG_TFOOT, TAG_TH, + TAG_THEAD, TAG_TR, TAG_BUTTON, TAG_DATALIST, TAG_FIELDSET, TAG_FORM, + TAG_INPUT, TAG_LABEL, TAG_LEGEND, TAG_METER, TAG_OPTGROUP, TAG_OPTION, + TAG_OUTPUT, TAG_PROGRESS, TAG_SELECT, TAG_TEXTAREA, TAG_DETAILS, + TAG_DIALOG, TAG_MENU, TAG_SUMMARY, TAG_BLINK, TAG_CENTER, TAG_CONTENT, + TAG_DIR, TAG_FONT, TAG_FRAME, TAG_NOFRAMES, TAG_FRAMESET, TAG_STRIKE, TAG_TT + +func getTagTypeMap(): Table[string, TagType] = + for i in low(TagType) .. high(TagType): + let enumname = $TagType(i) + let tagname = enumname.split('_')[1..^1].join("_").tolower() + result[tagname] = TagType(i) + +func getInputTypeMap(): Table[string, InputType] = + for i in low(InputType) .. high(InputType): + let enumname = $InputType(i) + let tagname = enumname.split('_')[1..^1].join("_").tolower() + result[tagname] = InputType(i) + +const tagTypeMap = getTagTypeMap() +const inputTypeMap = getInputTypeMap() + +func tagType*(s: string): TagType = + if tagTypeMap.hasKey(s): + return tagTypeMap[s] + else: + return TAG_UNKNOWN + +func inputType*(s: string): InputType = + if inputTypeMap.hasKey(s): + return inputTypeMap[s] + else: + return INPUT_UNKNOWN + +const SelfClosingTagTypes* = { + TAG_LI, TAG_P +} + +const VoidTagTypes* = { + TAG_AREA, TAG_BASE, TAG_BR, TAG_COL, TAG_FRAME, TAG_HR, TAG_IMG, TAG_INPUT, + TAG_SOURCE, TAG_TRACK, TAG_LINK, TAG_META, TAG_PARAM, TAG_WBR, TAG_HR +} + +const PClosingTagTypes* = { + TAG_ADDRESS, TAG_ARTICLE, TAG_ASIDE, TAG_BLOCKQUOTE, TAG_DETAILS, TAG_DIV, + TAG_DL, TAG_FIELDSET, TAG_FIGCAPTION, TAG_FIGURE, TAG_FOOTER, TAG_FORM, + TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TAG_HEADER, TAG_HGROUP, + TAG_HR, TAG_MAIN, TAG_MENU, TAG_NAV, TAG_OL, TAG_P, TAG_PRE, TAG_SECTION, + TAG_TABLE, TAG_UL +} + +const HeadTagTypes* = { + TAG_BASE, TAG_LINK, TAG_META, TAG_TITLE, TAG_NOSCRIPT, TAG_SCRIPT, TAG_NOFRAMES, TAG_STYLE, TAG_HEAD +} diff --git a/src/io/buffer.nim b/src/io/buffer.nim index cff179b6..785945d5 100644 --- a/src/io/buffer.nim +++ b/src/io/buffer.nim @@ -4,11 +4,11 @@ import strutils import unicode import streams -import types/enums import css/values import css/style import utils/twtstr import html/dom +import html/tags import layout/box import layout/engine import config/config diff --git a/src/layout/box.nim b/src/layout/box.nim index 679e7b57..d2546a85 100644 --- a/src/layout/box.nim +++ b/src/layout/box.nim @@ -1,6 +1,5 @@ import options -import types/enums import css/values import html/dom import io/term diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 646b5824..523b7bff 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -2,7 +2,7 @@ import unicode import options import layout/box -import types/enums +import html/tags import html/dom import css/values import utils/twtstr diff --git a/src/types/enums.nim b/src/types/enums.nim deleted file mode 100644 index 300744ba..00000000 --- a/src/types/enums.nim +++ /dev/null @@ -1,102 +0,0 @@ -type - NodeType* = enum - UNKNOWN_NODE = 0, - ELEMENT_NODE = 1, - ATTRIBUTE_NODE = 2, - TEXT_NODE = 3, - CDATA_SECTION_NODE = 4, - ENTITY_REFERENCE_NODE = 5, - ENTITY_NODE = 6 - PROCESSING_INSTRUCTION_NODE = 7, - COMMENT_NODE = 8, - DOCUMENT_NODE = 9, - DOCUMENT_TYPE_NODE = 10, - DOCUMENT_FRAGMENT_NODE = 11, - NOTATION_NODE = 12 - - InputType* = enum - INPUT_UNKNOWN, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_COLOR, INPUT_DATE, - INPUT_DATETIME_LOCAL, INPUT_EMAIL, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, - INPUT_MONTH, INPUT_NUMBER, INPUT_PASSWORD, INPUT_RADIO, INPUT_RANGE, - INPUT_RESET, INPUT_SEARCH, INPUT_SUBMIT, INPUT_TEL, INPUT_TEXT, INPUT_TIME, - INPUT_URL, INPUT_WEEK - - TagType* = enum - TAG_UNKNOWN, TAG_HTML, TAG_BASE, TAG_HEAD, TAG_LINK, TAG_META, TAG_STYLE, - TAG_TITLE, TAG_BODY, TAG_ADDRESS, TAG_ARTICLE, TAG_ASIDE, TAG_FOOTER, - TAG_HEADER, TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TAG_HGROUP, - TAG_MAIN, TAG_NAV, TAG_SECTION, TAG_BLOCKQUOTE, TAG_DD, TAG_DIV, TAG_DL, - TAG_DT, TAG_FIGCAPTION, TAG_FIGURE, TAG_HR, TAG_LI, TAG_OL, TAG_P, TAG_PRE, - TAG_UL, TAG_A, TAG_ABBR, TAG_B, TAG_BDI, TAG_BDO, TAG_BR, TAG_CITE, - TAG_CODE, TAG_DATA, TAG_DFN, TAG_EM, TAG_I, TAG_KBD, TAG_MARK, TAG_Q, - TAG_RB, TAG_RP, TAG_RT, TAG_RTC, TAG_RUBY, TAG_S, TAG_SAMP, TAG_SMALL, - TAG_SPAN, TAG_STRONG, TAG_SUB, TAG_SUP, TAG_TIME, TAG_U, TAG_VAR, TAG_WBR, - TAG_AREA, TAG_AUDIO, TAG_IMG, TAG_MAP, TAG_TRACK, TAG_VIDEO, - TAG_IFRAME, TAG_OBJECT, TAG_PARAM, TAG_PICTURE, TAG_PORTAL, TAG_SOURCE, - TAG_CANVAS, TAG_NOSCRIPT, TAG_SCRIPT, TAG_DEL, TAG_INS, TAG_CAPTION, - TAG_COL, TAG_COLGROUP, TAG_TABLE, TAG_TBODY, TAG_TD, TAG_TFOOT, TAG_TH, - TAG_THEAD, TAG_TR, TAG_BUTTON, TAG_DATALIST, TAG_FIELDSET, TAG_FORM, - TAG_INPUT, TAG_LABEL, TAG_LEGEND, TAG_METER, TAG_OPTGROUP, TAG_OPTION, - TAG_OUTPUT, TAG_PROGRESS, TAG_SELECT, TAG_TEXTAREA, TAG_DETAILS, - TAG_DIALOG, TAG_MENU, TAG_SUMMARY, TAG_BLINK, TAG_CENTER, TAG_CONTENT, - TAG_DIR, TAG_FONT, TAG_FRAME, TAG_NOFRAMES, TAG_FRAMESET, TAG_STRIKE, TAG_TT - - CSSTokenType* = enum - CSS_NO_TOKEN, CSS_IDENT_TOKEN, CSS_FUNCTION_TOKEN, CSS_AT_KEYWORD_TOKEN, - CSS_HASH_TOKEN, CSS_STRING_TOKEN, CSS_BAD_STRING_TOKEN, CSS_URL_TOKEN, - CSS_BAD_URL_TOKEN, CSS_DELIM_TOKEN, CSS_NUMBER_TOKEN, CSS_PERCENTAGE_TOKEN, - CSS_DIMENSION_TOKEN, CSS_WHITESPACE_TOKEN, CSS_CDO_TOKEN, CSS_CDC_TOKEN, - CSS_COLON_TOKEN, CSS_SEMICOLON_TOKEN, CSS_COMMA_TOKEN, CSS_RBRACKET_TOKEN, - CSS_LBRACKET_TOKEN, CSS_LPAREN_TOKEN, CSS_RPAREN_TOKEN, CSS_LBRACE_TOKEN, - CSS_RBRACE_TOKEN - - CSSUnit* = enum - UNIT_CM, UNIT_MM, UNIT_IN, UNIT_PX, UNIT_PT, UNIT_PC, - UNIT_EM, UNIT_EX, UNIT_CH, UNIT_REM, UNIT_VW, UNIT_VH, UNIT_VMIN, - UNIT_VMAX, UNIT_PERC, UNIT_IC - - CSSPropertyType* = enum - PROPERTY_NONE, PROPERTY_ALL, PROPERTY_COLOR, PROPERTY_MARGIN, - PROPERTY_MARGIN_TOP, PROPERTY_MARGIN_LEFT, PROPERTY_MARGIN_RIGHT, - PROPERTY_MARGIN_BOTTOM, PROPERTY_FONT_STYLE, PROPERTY_DISPLAY, - PROPERTY_CONTENT, PROPERTY_WHITE_SPACE, PROPERTY_FONT_WEIGHT, - PROPERTY_TEXT_DECORATION, PROPERTY_WORD_BREAK, PROPERTY_WIDTH, - PROPERTY_HEIGHT, PROPERTY_LIST_STYLE_TYPE - - CSSValueType* = enum - VALUE_NONE, VALUE_LENGTH, VALUE_COLOR, VALUE_CONTENT, VALUE_DISPLAY, - VALUE_FONT_STYLE, VALUE_WHITE_SPACE, VALUE_INTEGER, VALUE_TEXT_DECORATION, - VALUE_WORD_BREAK, VALUE_LIST_STYLE_TYPE - - CSSGlobalValueType* = enum - VALUE_NOGLOBAL, VALUE_INITIAL, VALUE_INHERIT, VALUE_REVERT, VALUE_UNSET - - CSSDisplay* = enum - DISPLAY_NONE, DISPLAY_INLINE, DISPLAY_BLOCK, DISPLAY_LIST_ITEM, - DISPLAY_INLINE_BLOCK, DISPLAY_TABLE, DISPLAY_TABLE_ROW_GROUP, - DISPLAY_TABLE_HEADER_GROUP, DISPLAY_TABLE_FOOTER_GROUP, - DISPLAY_TABLE_COLUMN_GROUP, DISPLAY_TABLE_ROW, DISPLAY_TABLE_COLUMN, - DISPLAY_TABLE_CELL - - CSSWhitespace* = enum - WHITESPACE_NORMAL, WHITESPACE_NOWRAP, WHITESPACE_PRE, WHITESPACE_PRE_LINE, - WHITESPACE_PRE_WRAP - - CSSFontStyle* = enum - FONTSTYLE_NORMAL, FONTSTYLE_ITALIC, FONTSTYLE_OBLIQUE - - CSSPosition* = enum - POSITION_STATIC, POSITION_RELATIVE, POSITION_ABSOLUTE, POSITION_FIXED, - POSITION_INHERIT - - CSSTextDecoration* = enum - TEXT_DECORATION_NONE, TEXT_DECORATION_UNDERLINE, TEXT_DECORATION_OVERLINE, - TEXT_DECORATION_LINE_THROUGH, TEXT_DECORATION_BLINK - - CSSWordBreak* = enum - WORD_BREAK_NORMAL, WORD_BREAK_BREAK_ALL, WORD_BREAK_KEEP_ALL - - CSSListStyleType* = enum - LIST_STYLE_TYPE_NONE, LIST_STYLE_TYPE_DISC, LIST_STYLE_TYPE_CIRCLE, - LIST_STYLE_TYPE_SQUARE, LIST_STYLE_TYPE_DECIMAL, - LIST_STYLE_TYPE_JAPANESE_INFORMAL diff --git a/src/types/tagtypes.nim b/src/types/tagtypes.nim deleted file mode 100644 index 14121db0..00000000 --- a/src/types/tagtypes.nim +++ /dev/null @@ -1,51 +0,0 @@ -import tables -import enums -import strutils - -func getTagTypeMap(): Table[string, TagType] = - for i in low(TagType) .. high(TagType): - let enumname = $TagType(i) - let tagname = enumname.split('_')[1..^1].join("_").tolower() - result[tagname] = TagType(i) - -func getInputTypeMap(): Table[string, InputType] = - for i in low(InputType) .. high(InputType): - let enumname = $InputType(i) - let tagname = enumname.split('_')[1..^1].join("_").tolower() - result[tagname] = InputType(i) - -const tagTypeMap = getTagTypeMap() -const inputTypeMap = getInputTypeMap() - -func tagType*(s: string): TagType = - if tagTypeMap.hasKey(s): - return tagTypeMap[s] - else: - return TAG_UNKNOWN - -func inputType*(s: string): InputType = - if inputTypeMap.hasKey(s): - return inputTypeMap[s] - else: - return INPUT_UNKNOWN - -const SelfClosingTagTypes* = { - TAG_LI, TAG_P -} - -const VoidTagTypes* = { - TAG_AREA, TAG_BASE, TAG_BR, TAG_COL, TAG_FRAME, TAG_HR, TAG_IMG, TAG_INPUT, - TAG_SOURCE, TAG_TRACK, TAG_LINK, TAG_META, TAG_PARAM, TAG_WBR, TAG_HR -} - -const PClosingTagTypes* = { - TAG_ADDRESS, TAG_ARTICLE, TAG_ASIDE, TAG_BLOCKQUOTE, TAG_DETAILS, TAG_DIV, - TAG_DL, TAG_FIELDSET, TAG_FIGCAPTION, TAG_FIGURE, TAG_FOOTER, TAG_FORM, - TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TAG_HEADER, TAG_HGROUP, - TAG_HR, TAG_MAIN, TAG_MENU, TAG_NAV, TAG_OL, TAG_P, TAG_PRE, TAG_SECTION, - TAG_TABLE, TAG_UL -} - -const HeadTagTypes* = { - TAG_BASE, TAG_LINK, TAG_META, TAG_TITLE, TAG_NOSCRIPT, TAG_SCRIPT, TAG_NOFRAMES, TAG_STYLE, TAG_HEAD -} |