diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 14:21:53 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 14:21:53 +0200 |
commit | 504729a4a0c8f3e0d8fc9159e0273150b169e184 (patch) | |
tree | a6bf291322decccd6011580337b1feed6151b554 /src/content/text.rs | |
parent | db5a491e6c2223d1db9b458307431a54db3c40f2 (diff) | |
download | markdown-rs-504729a4a0c8f3e0d8fc9159e0273150b169e184.tar.gz markdown-rs-504729a4a0c8f3e0d8fc9159e0273150b169e184.tar.bz2 markdown-rs-504729a4a0c8f3e0d8fc9159e0273150b169e184.zip |
Refactor to improve docs of each function
Diffstat (limited to 'src/content/text.rs')
-rw-r--r-- | src/content/text.rs | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/content/text.rs b/src/content/text.rs index 6509d30..5c13dba 100644 --- a/src/content/text.rs +++ b/src/content/text.rs @@ -25,6 +25,7 @@ use crate::resolve::Name as ResolveName; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; +/// Characters that can start something in text. const MARKERS: [u8; 9] = [ b'!', // `label_start_image` b'&', // `character_reference` @@ -38,6 +39,11 @@ const MARKERS: [u8; 9] = [ ]; /// Start of text. +/// +/// ```markdown +/// > | abc +/// ^ +/// ``` pub fn start(tokenizer: &mut Tokenizer) -> State { tokenizer.register_resolver(ResolveName::Text); tokenizer.tokenize_state.markers = &MARKERS; @@ -45,6 +51,11 @@ pub fn start(tokenizer: &mut Tokenizer) -> State { } /// Before text. +/// +/// ```markdown +/// > | abc +/// ^ +/// ``` pub fn before(tokenizer: &mut Tokenizer) -> State { match tokenizer.current { None => State::Ok, @@ -109,7 +120,14 @@ pub fn before(tokenizer: &mut Tokenizer) -> State { } } -/// At `<`, which wasn’t an autolink: before HTML? +/// Before html (text). +/// +/// At `<`, which wasn’t an autolink. +/// +/// ```markdown +/// > | a <b> +/// ^ +/// ``` pub fn before_html(tokenizer: &mut Tokenizer) -> State { tokenizer.attempt( State::Next(StateName::TextBefore), @@ -118,7 +136,14 @@ pub fn before_html(tokenizer: &mut Tokenizer) -> State { State::Retry(StateName::HtmlTextStart) } -/// At `\`, which wasn’t a character escape: before a hard break? +/// Before hard break escape. +/// +/// At `\`, which wasn’t a character escape. +/// +/// ```markdown +/// > | a \␊ +/// ^ +/// ``` pub fn before_hard_break_escape(tokenizer: &mut Tokenizer) -> State { tokenizer.attempt( State::Next(StateName::TextBefore), @@ -127,7 +152,12 @@ pub fn before_hard_break_escape(tokenizer: &mut Tokenizer) -> State { State::Retry(StateName::HardBreakEscapeStart) } -/// At data. +/// Before data. +/// +/// ```markdown +/// > | a +/// ^ +/// ``` pub fn before_data(tokenizer: &mut Tokenizer) -> State { tokenizer.attempt(State::Next(StateName::TextBefore), State::Nok); State::Retry(StateName::DataStart) |