diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-15 12:34:23 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-15 12:36:36 +0200 |
commit | 66c70d1b917976c32b770e5d724fc4e47a2309c6 (patch) | |
tree | faac63df2b0687d15f7de556d765f6c93a3d7dd1 /src | |
parent | 21dbf42b5e5979fb30837bbb3b2638dcf5711249 (diff) | |
download | markdown-rs-66c70d1b917976c32b770e5d724fc4e47a2309c6.tar.gz markdown-rs-66c70d1b917976c32b770e5d724fc4e47a2309c6.tar.bz2 markdown-rs-66c70d1b917976c32b770e5d724fc4e47a2309c6.zip |
Refactor to sort, document lists in token
Diffstat (limited to '')
-rw-r--r-- | src/compiler.rs | 3 | ||||
-rw-r--r-- | src/constant.rs | 1 | ||||
-rw-r--r-- | src/token.rs | 139 |
3 files changed, 131 insertions, 12 deletions
diff --git a/src/compiler.rs b/src/compiler.rs index 7b50147..6484aaa 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -723,8 +723,7 @@ fn on_enter_list(context: &mut CompileContext) { // Blank line directly in list or directly in list item, // but not a blank line after an empty list item. - if balance < 3 && event.token_type == Token::BlankLineEnding - { + if balance < 3 && event.token_type == Token::BlankLineEnding { let at_marker = balance == 2 && events[skip::opt_back( events, diff --git a/src/constant.rs b/src/constant.rs index 2c74083..a5ace28 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -193,7 +193,6 @@ pub const HTML_RAW_SIZE_MAX: usize = 8; /// To safeguard performance, labels are capped at a large number: `999`. pub const LINK_REFERENCE_SIZE_MAX: usize = 999; - /// The max number of decimals allowed to form an (ordered) [list][] item. /// /// `CommonMark` caps this at 10 digits (9 is fine, 10 not). diff --git a/src/token.rs b/src/token.rs index 889c3ba..825b9cd 100644 --- a/src/token.rs +++ b/src/token.rs @@ -1386,6 +1386,136 @@ pub enum Token { /// ^^^^^^ /// ``` Link, + /// List item. + /// + /// ## Info + /// + /// * **Context**: + /// [`ListOrdered`][Token::ListOrdered], + /// [`ListUnordered`][Token::ListUnordered], + /// * **Content model**: + /// [`ListItemPrefix`][Token::ListItemPrefix], + /// [flow content][crate::content::flow] + /// * **Construct**: + /// [`list`][crate::construct::list] + /// + /// ## Example + /// + /// ```markdown + /// > | * a + /// ^^^ + /// > | 1. b + /// ^^^^ + /// ``` + ListItem, + /// List item (marker). + /// + /// ## Info + /// + /// * **Context**: + /// [`ListItemPrefix`][Token::ListItemPrefix] + /// * **Content model**: + /// void + /// * **Construct**: + /// [`list`][crate::construct::list] + /// + /// ## Example + /// + /// ```markdown + /// > | * a + /// ^ + /// > | 1. b + /// ^ + /// ``` + ListItemMarker, + /// List item (prefix). + /// + /// ## Info + /// + /// * **Context**: + /// [`ListItem`][Token::ListItem] + /// * **Content model**: + /// [`ListItemMarker`][Token::ListItemMarker], + /// [`ListItemValue`][Token::ListItemValue], + /// [`SpaceOrTab`][Token::SpaceOrTab] + /// * **Construct**: + /// [`list`][crate::construct::list] + /// + /// ## Example + /// + /// ```markdown + /// > | * a + /// ^^ + /// > | b + /// ^^ + /// ``` + ListItemPrefix, + /// List item (value). + /// + /// ## Info + /// + /// * **Context**: + /// [`ListItemPrefix`][Token::ListItemPrefix] + /// * **Content model**: + /// void + /// * **Construct**: + /// [`list`][crate::construct::list] + /// + /// ## Example + /// + /// ```markdown + /// > | 1. b + /// ^ + /// ``` + ListItemValue, + /// List (ordered). + /// + /// ## Info + /// + /// * **Context**: + /// [document content][crate::content::document] + /// * **Content model**: + /// [`BlankLineEnding`][Token::BlankLineEnding], + /// [`BlockQuotePrefix`][Token::BlockQuotePrefix], + /// [`ListItem`][Token::ListItem], + /// [`LineEnding`][Token::LineEnding], + /// [`SpaceOrTab`][Token::SpaceOrTab] + /// * **Construct**: + /// [`list`][crate::construct::list] + /// + /// ## Example + /// + /// ```markdown + /// > | 1. a + /// ^^^^ + /// > | 2. b + /// ^^^^ + /// ``` + ListOrdered, + /// List (unordered). + /// + /// ## Info + /// + /// * **Context**: + /// [document content][crate::content::document] + /// * **Content model**: + /// [`BlankLineEnding`][Token::BlankLineEnding], + /// [`BlockQuotePrefix`][Token::BlockQuotePrefix], + /// [`ListItem`][Token::ListItem], + /// [`LineEnding`][Token::LineEnding], + /// [`SpaceOrTab`][Token::SpaceOrTab] + /// * **Construct**: + /// [`list`][crate::construct::list] + /// + /// ## Example + /// + /// ```markdown + /// > | * a + /// ^^^ + /// > | * b + /// ^^^ + /// ``` + ListUnordered, /// Whole paragraph. /// /// ## Info @@ -1765,13 +1895,4 @@ pub enum Token { /// ^ ^ ^ /// ``` ThematicBreakSequence, - - // To do: sort. - ListOrdered, - ListUnordered, - ListItem, - ListItemPrefix, - ListItemValue, - ListItemMarker, - // ListItemPrefixSpaceOrTab, } |