diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-09-08 16:40:42 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-09-08 16:40:42 +0200 |
commit | d1392983e44870a7fa50eaf77da4a5741011f5c7 (patch) | |
tree | f3283ddb5d0e0b74ae0bcb864f3592d8809235f7 /src/state.rs | |
parent | 05b18d445394d4eaadb42ab5d4606eecdaf21876 (diff) | |
download | markdown-rs-d1392983e44870a7fa50eaf77da4a5741011f5c7.tar.gz markdown-rs-d1392983e44870a7fa50eaf77da4a5741011f5c7.tar.bz2 markdown-rs-d1392983e44870a7fa50eaf77da4a5741011f5c7.zip |
Refactor to order states
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 391 |
1 files changed, 194 insertions, 197 deletions
diff --git a/src/state.rs b/src/state.rs index 472a801..4201f5c 100644 --- a/src/state.rs +++ b/src/state.rs @@ -171,6 +171,29 @@ pub enum Name { FrontmatterCloseSequence, FrontmatterCloseAfter, + GfmAutolinkLiteralProtocolStart, + GfmAutolinkLiteralProtocolAfter, + GfmAutolinkLiteralProtocolPrefixInside, + GfmAutolinkLiteralProtocolSlashesInside, + + GfmAutolinkLiteralWwwStart, + GfmAutolinkLiteralWwwAfter, + GfmAutolinkLiteralWwwPrefixInside, + GfmAutolinkLiteralWwwPrefixAfter, + + GfmAutolinkLiteralDomainInside, + GfmAutolinkLiteralDomainAtPunctuation, + GfmAutolinkLiteralDomainAfter, + + GfmAutolinkLiteralPathInside, + GfmAutolinkLiteralPathAtPunctuation, + GfmAutolinkLiteralPathAfter, + + GfmAutolinkLiteralTrail, + GfmAutolinkLiteralTrailCharRefInside, + GfmAutolinkLiteralTrailCharRefStart, + GfmAutolinkLiteralTrailBracketAfter, + GfmFootnoteDefinitionStart, GfmFootnoteDefinitionLabelBefore, GfmFootnoteDefinitionLabelAfter, @@ -188,6 +211,28 @@ pub enum Name { GfmTaskListItemCheckAfter, GfmTaskListItemCheckAfterSpaceOrTab, + GfmTableStart, + GfmTableHeadRowBefore, + GfmTableHeadRowStart, + GfmTableHeadRowBreak, + GfmTableHeadRowData, + GfmTableHeadRowEscape, + GfmTableHeadDelimiterStart, + GfmTableHeadDelimiterBefore, + GfmTableHeadDelimiterCellBefore, + GfmTableHeadDelimiterValueBefore, + GfmTableHeadDelimiterLeftAlignmentAfter, + GfmTableHeadDelimiterFiller, + GfmTableHeadDelimiterRightAlignmentAfter, + GfmTableHeadDelimiterCellAfter, + GfmTableHeadDelimiterNok, + + GfmTableBodyRowBefore, + GfmTableBodyRowStart, + GfmTableBodyRowBreak, + GfmTableBodyRowData, + GfmTableBodyRowEscape, + HardBreakEscapeStart, HardBreakEscapeAfter, @@ -314,6 +359,43 @@ pub enum Name { ListItemContBlank, ListItemContFilled, + MdxJsxFlowStart, + MdxJsxFlowBefore, + MdxJsxFlowAfter, + MdxJsxFlowEnd, + MdxJsxFlowNok, + MdxJsxTextStart, + MdxJsxTextAfter, + MdxJsxTextNok, + MdxJsxEsWhitespaceStart, + MdxJsxEsWhitespaceInside, + MdxJsxEsWhitespaceEol, + MdxJsxEsWhitespaceEolAfter, + MdxJsxEsWhitespaceEolAfterInside, + MdxJsxStart, + MdxJsxStartAfter, + MdxJsxNameBefore, + MdxJsxClosingTagNameBefore, + MdxJsxTagEnd, + MdxJsxPrimaryName, + MdxJsxPrimaryNameAfter, + MdxJsxMemberNameBefore, + MdxJsxMemberName, + MdxJsxMemberNameAfter, + MdxJsxLocalNameBefore, + MdxJsxLocalName, + MdxJsxLocalNameAfter, + MdxJsxAttributeBefore, + MdxJsxSelfClosing, + MdxJsxAttributePrimaryName, + MdxJsxAttributePrimaryNameAfter, + MdxJsxAttributeLocalNameBefore, + MdxJsxAttributeLocalName, + MdxJsxAttributeLocalNameAfter, + MdxJsxAttributeValueBefore, + MdxJsxAttributeValueQuotedStart, + MdxJsxAttributeValueQuoted, + NonLazyContinuationStart, NonLazyContinuationAfter, @@ -334,51 +416,6 @@ pub enum Name { StringBefore, StringBeforeData, - GfmAutolinkLiteralProtocolStart, - GfmAutolinkLiteralProtocolAfter, - GfmAutolinkLiteralProtocolPrefixInside, - GfmAutolinkLiteralProtocolSlashesInside, - - GfmAutolinkLiteralWwwStart, - GfmAutolinkLiteralWwwAfter, - GfmAutolinkLiteralWwwPrefixInside, - GfmAutolinkLiteralWwwPrefixAfter, - - GfmAutolinkLiteralDomainInside, - GfmAutolinkLiteralDomainAtPunctuation, - GfmAutolinkLiteralDomainAfter, - - GfmAutolinkLiteralPathInside, - GfmAutolinkLiteralPathAtPunctuation, - GfmAutolinkLiteralPathAfter, - - GfmAutolinkLiteralTrail, - GfmAutolinkLiteralTrailCharRefInside, - GfmAutolinkLiteralTrailCharRefStart, - GfmAutolinkLiteralTrailBracketAfter, - - GfmTableStart, - GfmTableHeadRowBefore, - GfmTableHeadRowStart, - GfmTableHeadRowBreak, - GfmTableHeadRowData, - GfmTableHeadRowEscape, - GfmTableHeadDelimiterStart, - GfmTableHeadDelimiterBefore, - GfmTableHeadDelimiterCellBefore, - GfmTableHeadDelimiterValueBefore, - GfmTableHeadDelimiterLeftAlignmentAfter, - GfmTableHeadDelimiterFiller, - GfmTableHeadDelimiterRightAlignmentAfter, - GfmTableHeadDelimiterCellAfter, - GfmTableHeadDelimiterNok, - - GfmTableBodyRowBefore, - GfmTableBodyRowStart, - GfmTableBodyRowBreak, - GfmTableBodyRowData, - GfmTableBodyRowEscape, - TextStart, TextBefore, TextBeforeHtml, @@ -399,100 +436,12 @@ pub enum Name { TitleAtBlankLine, TitleEscape, TitleInside, - - // To do: sort. - MdxJsxFlowStart, - MdxJsxFlowBefore, - MdxJsxFlowAfter, - MdxJsxFlowEnd, - MdxJsxFlowNok, - MdxJsxTextStart, - MdxJsxTextAfter, - MdxJsxTextNok, - MdxJsxEsWhitespaceStart, - MdxJsxEsWhitespaceInside, - MdxJsxEsWhitespaceEol, - MdxJsxEsWhitespaceEolAfter, - MdxJsxEsWhitespaceEolAfterInside, - MdxJsxStart, - MdxJsxStartAfter, - MdxJsxNameBefore, - MdxJsxClosingTagNameBefore, - MdxJsxTagEnd, - MdxJsxPrimaryName, - MdxJsxPrimaryNameAfter, - MdxJsxMemberNameBefore, - MdxJsxMemberName, - MdxJsxMemberNameAfter, - MdxJsxLocalNameBefore, - MdxJsxLocalName, - MdxJsxLocalNameAfter, - MdxJsxAttributeBefore, - MdxJsxSelfClosing, - MdxJsxAttributePrimaryName, - MdxJsxAttributePrimaryNameAfter, - MdxJsxAttributeLocalNameBefore, - MdxJsxAttributeLocalName, - MdxJsxAttributeLocalNameAfter, - MdxJsxAttributeValueBefore, - MdxJsxAttributeValueQuotedStart, - MdxJsxAttributeValueQuoted, } #[allow(clippy::too_many_lines)] /// Call the corresponding state for a state name. pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State { let func = match name { - // To do: sort. - Name::MdxJsxFlowStart => construct::mdx_jsx_flow::start, - Name::MdxJsxFlowBefore => construct::mdx_jsx_flow::before, - Name::MdxJsxFlowAfter => construct::mdx_jsx_flow::after, - Name::MdxJsxFlowEnd => construct::mdx_jsx_flow::end, - Name::MdxJsxFlowNok => construct::mdx_jsx_flow::nok, - Name::MdxJsxTextStart => construct::mdx_jsx_text::start, - Name::MdxJsxTextAfter => construct::mdx_jsx_text::after, - Name::MdxJsxTextNok => construct::mdx_jsx_text::nok, - - Name::MdxJsxEsWhitespaceStart => construct::partial_mdx_jsx::es_whitespace_start, - Name::MdxJsxEsWhitespaceInside => construct::partial_mdx_jsx::es_whitespace_inside, - Name::MdxJsxEsWhitespaceEol => construct::partial_mdx_jsx::es_whitespace_eol, - Name::MdxJsxEsWhitespaceEolAfter => construct::partial_mdx_jsx::es_whitespace_eol_after, - Name::MdxJsxEsWhitespaceEolAfterInside => { - construct::partial_mdx_jsx::es_whitespace_eol_after_inside - } - - Name::MdxJsxStart => construct::partial_mdx_jsx::start, - Name::MdxJsxStartAfter => construct::partial_mdx_jsx::start_after, - Name::MdxJsxNameBefore => construct::partial_mdx_jsx::name_before, - Name::MdxJsxClosingTagNameBefore => construct::partial_mdx_jsx::closing_tag_name_before, - Name::MdxJsxTagEnd => construct::partial_mdx_jsx::tag_end, - Name::MdxJsxPrimaryName => construct::partial_mdx_jsx::primary_name, - Name::MdxJsxPrimaryNameAfter => construct::partial_mdx_jsx::primary_name_after, - Name::MdxJsxMemberNameBefore => construct::partial_mdx_jsx::member_name_before, - Name::MdxJsxMemberName => construct::partial_mdx_jsx::member_name, - Name::MdxJsxMemberNameAfter => construct::partial_mdx_jsx::member_name_after, - Name::MdxJsxLocalNameBefore => construct::partial_mdx_jsx::local_name_before, - Name::MdxJsxLocalName => construct::partial_mdx_jsx::local_name, - Name::MdxJsxLocalNameAfter => construct::partial_mdx_jsx::local_name_after, - Name::MdxJsxAttributeBefore => construct::partial_mdx_jsx::attribute_before, - Name::MdxJsxSelfClosing => construct::partial_mdx_jsx::self_closing, - Name::MdxJsxAttributePrimaryName => construct::partial_mdx_jsx::attribute_primary_name, - Name::MdxJsxAttributePrimaryNameAfter => { - construct::partial_mdx_jsx::attribute_primary_name_after - } - Name::MdxJsxAttributeLocalNameBefore => { - construct::partial_mdx_jsx::attribute_local_name_before - } - Name::MdxJsxAttributeLocalName => construct::partial_mdx_jsx::attribute_local_name, - Name::MdxJsxAttributeLocalNameAfter => { - construct::partial_mdx_jsx::attribute_local_name_after - } - Name::MdxJsxAttributeValueBefore => construct::partial_mdx_jsx::attribute_value_before, - Name::MdxJsxAttributeValueQuotedStart => { - construct::partial_mdx_jsx::attribute_value_quoted_start - } - Name::MdxJsxAttributeValueQuoted => construct::partial_mdx_jsx::attribute_value_quoted, - Name::AttentionStart => construct::attention::start, Name::AttentionInside => construct::attention::inside, @@ -629,6 +578,43 @@ pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State { Name::FrontmatterCloseSequence => construct::frontmatter::close_sequence, Name::FrontmatterCloseAfter => construct::frontmatter::close_after, + Name::GfmAutolinkLiteralProtocolStart => construct::gfm_autolink_literal::protocol_start, + Name::GfmAutolinkLiteralProtocolAfter => construct::gfm_autolink_literal::protocol_after, + Name::GfmAutolinkLiteralProtocolPrefixInside => { + construct::gfm_autolink_literal::protocol_prefix_inside + } + Name::GfmAutolinkLiteralProtocolSlashesInside => { + construct::gfm_autolink_literal::protocol_slashes_inside + } + + Name::GfmAutolinkLiteralWwwAfter => construct::gfm_autolink_literal::www_after, + Name::GfmAutolinkLiteralWwwStart => construct::gfm_autolink_literal::www_start, + Name::GfmAutolinkLiteralWwwPrefixInside => { + construct::gfm_autolink_literal::www_prefix_inside + } + Name::GfmAutolinkLiteralWwwPrefixAfter => construct::gfm_autolink_literal::www_prefix_after, + Name::GfmAutolinkLiteralDomainInside => construct::gfm_autolink_literal::domain_inside, + Name::GfmAutolinkLiteralDomainAtPunctuation => { + construct::gfm_autolink_literal::domain_at_punctuation + } + Name::GfmAutolinkLiteralDomainAfter => construct::gfm_autolink_literal::domain_after, + + Name::GfmAutolinkLiteralPathInside => construct::gfm_autolink_literal::path_inside, + Name::GfmAutolinkLiteralPathAtPunctuation => { + construct::gfm_autolink_literal::path_at_punctuation + } + Name::GfmAutolinkLiteralPathAfter => construct::gfm_autolink_literal::path_after, + Name::GfmAutolinkLiteralTrail => construct::gfm_autolink_literal::trail, + Name::GfmAutolinkLiteralTrailCharRefStart => { + construct::gfm_autolink_literal::trail_char_ref_start + } + Name::GfmAutolinkLiteralTrailCharRefInside => { + construct::gfm_autolink_literal::trail_char_ref_inside + } + Name::GfmAutolinkLiteralTrailBracketAfter => { + construct::gfm_autolink_literal::trail_bracket_after + } + Name::GfmFootnoteDefinitionStart => construct::gfm_footnote_definition::start, Name::GfmFootnoteDefinitionLabelBefore => construct::gfm_footnote_definition::label_before, Name::GfmFootnoteDefinitionLabelAfter => construct::gfm_footnote_definition::label_after, @@ -650,6 +636,33 @@ pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State { construct::gfm_task_list_item_check::after_space_or_tab } + Name::GfmTableStart => construct::gfm_table::start, + Name::GfmTableHeadRowBefore => construct::gfm_table::head_row_before, + Name::GfmTableHeadRowStart => construct::gfm_table::head_row_start, + Name::GfmTableHeadRowBreak => construct::gfm_table::head_row_break, + Name::GfmTableHeadRowData => construct::gfm_table::head_row_data, + Name::GfmTableHeadRowEscape => construct::gfm_table::head_row_escape, + + Name::GfmTableHeadDelimiterStart => construct::gfm_table::head_delimiter_start, + Name::GfmTableHeadDelimiterBefore => construct::gfm_table::head_delimiter_before, + Name::GfmTableHeadDelimiterCellBefore => construct::gfm_table::head_delimiter_cell_before, + Name::GfmTableHeadDelimiterValueBefore => construct::gfm_table::head_delimiter_value_before, + Name::GfmTableHeadDelimiterLeftAlignmentAfter => { + construct::gfm_table::head_delimiter_left_alignment_after + } + Name::GfmTableHeadDelimiterFiller => construct::gfm_table::head_delimiter_filler, + Name::GfmTableHeadDelimiterRightAlignmentAfter => { + construct::gfm_table::head_delimiter_right_alignment_after + } + Name::GfmTableHeadDelimiterCellAfter => construct::gfm_table::head_delimiter_cell_after, + Name::GfmTableHeadDelimiterNok => construct::gfm_table::head_delimiter_nok, + + Name::GfmTableBodyRowBefore => construct::gfm_table::body_row_before, + Name::GfmTableBodyRowStart => construct::gfm_table::body_row_start, + Name::GfmTableBodyRowBreak => construct::gfm_table::body_row_break, + Name::GfmTableBodyRowData => construct::gfm_table::body_row_data, + Name::GfmTableBodyRowEscape => construct::gfm_table::body_row_escape, + Name::HardBreakEscapeStart => construct::hard_break_escape::start, Name::HardBreakEscapeAfter => construct::hard_break_escape::after, @@ -803,6 +816,54 @@ pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State { Name::ListItemContBlank => construct::list_item::cont_blank, Name::ListItemContFilled => construct::list_item::cont_filled, + Name::MdxJsxFlowStart => construct::mdx_jsx_flow::start, + Name::MdxJsxFlowBefore => construct::mdx_jsx_flow::before, + Name::MdxJsxFlowAfter => construct::mdx_jsx_flow::after, + Name::MdxJsxFlowEnd => construct::mdx_jsx_flow::end, + Name::MdxJsxFlowNok => construct::mdx_jsx_flow::nok, + Name::MdxJsxTextStart => construct::mdx_jsx_text::start, + Name::MdxJsxTextAfter => construct::mdx_jsx_text::after, + Name::MdxJsxTextNok => construct::mdx_jsx_text::nok, + + Name::MdxJsxStart => construct::partial_mdx_jsx::start, + Name::MdxJsxStartAfter => construct::partial_mdx_jsx::start_after, + Name::MdxJsxNameBefore => construct::partial_mdx_jsx::name_before, + Name::MdxJsxClosingTagNameBefore => construct::partial_mdx_jsx::closing_tag_name_before, + Name::MdxJsxTagEnd => construct::partial_mdx_jsx::tag_end, + Name::MdxJsxPrimaryName => construct::partial_mdx_jsx::primary_name, + Name::MdxJsxPrimaryNameAfter => construct::partial_mdx_jsx::primary_name_after, + Name::MdxJsxMemberNameBefore => construct::partial_mdx_jsx::member_name_before, + Name::MdxJsxMemberName => construct::partial_mdx_jsx::member_name, + Name::MdxJsxMemberNameAfter => construct::partial_mdx_jsx::member_name_after, + Name::MdxJsxLocalNameBefore => construct::partial_mdx_jsx::local_name_before, + Name::MdxJsxLocalName => construct::partial_mdx_jsx::local_name, + Name::MdxJsxLocalNameAfter => construct::partial_mdx_jsx::local_name_after, + Name::MdxJsxAttributeBefore => construct::partial_mdx_jsx::attribute_before, + Name::MdxJsxSelfClosing => construct::partial_mdx_jsx::self_closing, + Name::MdxJsxAttributePrimaryName => construct::partial_mdx_jsx::attribute_primary_name, + Name::MdxJsxAttributePrimaryNameAfter => { + construct::partial_mdx_jsx::attribute_primary_name_after + } + Name::MdxJsxAttributeLocalNameBefore => { + construct::partial_mdx_jsx::attribute_local_name_before + } + Name::MdxJsxAttributeLocalName => construct::partial_mdx_jsx::attribute_local_name, + Name::MdxJsxAttributeLocalNameAfter => { + construct::partial_mdx_jsx::attribute_local_name_after + } + Name::MdxJsxAttributeValueBefore => construct::partial_mdx_jsx::attribute_value_before, + Name::MdxJsxAttributeValueQuotedStart => { + construct::partial_mdx_jsx::attribute_value_quoted_start + } + Name::MdxJsxAttributeValueQuoted => construct::partial_mdx_jsx::attribute_value_quoted, + Name::MdxJsxEsWhitespaceStart => construct::partial_mdx_jsx::es_whitespace_start, + Name::MdxJsxEsWhitespaceInside => construct::partial_mdx_jsx::es_whitespace_inside, + Name::MdxJsxEsWhitespaceEol => construct::partial_mdx_jsx::es_whitespace_eol, + Name::MdxJsxEsWhitespaceEolAfter => construct::partial_mdx_jsx::es_whitespace_eol_after, + Name::MdxJsxEsWhitespaceEolAfterInside => { + construct::partial_mdx_jsx::es_whitespace_eol_after_inside + } + Name::NonLazyContinuationStart => construct::partial_non_lazy_continuation::start, Name::NonLazyContinuationAfter => construct::partial_non_lazy_continuation::after, @@ -823,70 +884,6 @@ pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State { Name::StringBefore => construct::string::before, Name::StringBeforeData => construct::string::before_data, - Name::GfmAutolinkLiteralProtocolStart => construct::gfm_autolink_literal::protocol_start, - Name::GfmAutolinkLiteralProtocolAfter => construct::gfm_autolink_literal::protocol_after, - Name::GfmAutolinkLiteralProtocolPrefixInside => { - construct::gfm_autolink_literal::protocol_prefix_inside - } - Name::GfmAutolinkLiteralProtocolSlashesInside => { - construct::gfm_autolink_literal::protocol_slashes_inside - } - - Name::GfmAutolinkLiteralWwwAfter => construct::gfm_autolink_literal::www_after, - Name::GfmAutolinkLiteralWwwStart => construct::gfm_autolink_literal::www_start, - Name::GfmAutolinkLiteralWwwPrefixInside => { - construct::gfm_autolink_literal::www_prefix_inside - } - Name::GfmAutolinkLiteralWwwPrefixAfter => construct::gfm_autolink_literal::www_prefix_after, - Name::GfmAutolinkLiteralDomainInside => construct::gfm_autolink_literal::domain_inside, - Name::GfmAutolinkLiteralDomainAtPunctuation => { - construct::gfm_autolink_literal::domain_at_punctuation - } - Name::GfmAutolinkLiteralDomainAfter => construct::gfm_autolink_literal::domain_after, - - Name::GfmAutolinkLiteralPathInside => construct::gfm_autolink_literal::path_inside, - Name::GfmAutolinkLiteralPathAtPunctuation => { - construct::gfm_autolink_literal::path_at_punctuation - } - Name::GfmAutolinkLiteralPathAfter => construct::gfm_autolink_literal::path_after, - Name::GfmAutolinkLiteralTrail => construct::gfm_autolink_literal::trail, - Name::GfmAutolinkLiteralTrailCharRefStart => { - construct::gfm_autolink_literal::trail_char_ref_start - } - Name::GfmAutolinkLiteralTrailCharRefInside => { - construct::gfm_autolink_literal::trail_char_ref_inside - } - Name::GfmAutolinkLiteralTrailBracketAfter => { - construct::gfm_autolink_literal::trail_bracket_after - } - - Name::GfmTableStart => construct::gfm_table::start, - Name::GfmTableHeadRowBefore => construct::gfm_table::head_row_before, - Name::GfmTableHeadRowStart => construct::gfm_table::head_row_start, - Name::GfmTableHeadRowBreak => construct::gfm_table::head_row_break, - Name::GfmTableHeadRowData => construct::gfm_table::head_row_data, - Name::GfmTableHeadRowEscape => construct::gfm_table::head_row_escape, - - Name::GfmTableHeadDelimiterStart => construct::gfm_table::head_delimiter_start, - Name::GfmTableHeadDelimiterBefore => construct::gfm_table::head_delimiter_before, - Name::GfmTableHeadDelimiterCellBefore => construct::gfm_table::head_delimiter_cell_before, - Name::GfmTableHeadDelimiterValueBefore => construct::gfm_table::head_delimiter_value_before, - Name::GfmTableHeadDelimiterLeftAlignmentAfter => { - construct::gfm_table::head_delimiter_left_alignment_after - } - Name::GfmTableHeadDelimiterFiller => construct::gfm_table::head_delimiter_filler, - Name::GfmTableHeadDelimiterRightAlignmentAfter => { - construct::gfm_table::head_delimiter_right_alignment_after - } - Name::GfmTableHeadDelimiterCellAfter => construct::gfm_table::head_delimiter_cell_after, - Name::GfmTableHeadDelimiterNok => construct::gfm_table::head_delimiter_nok, - - Name::GfmTableBodyRowBefore => construct::gfm_table::body_row_before, - Name::GfmTableBodyRowStart => construct::gfm_table::body_row_start, - Name::GfmTableBodyRowBreak => construct::gfm_table::body_row_break, - Name::GfmTableBodyRowData => construct::gfm_table::body_row_data, - Name::GfmTableBodyRowEscape => construct::gfm_table::body_row_escape, - Name::TextStart => construct::text::start, Name::TextBefore => construct::text::before, Name::TextBeforeHtml => construct::text::before_html, |