From 504729a4a0c8f3e0d8fc9159e0273150b169e184 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 12 Aug 2022 14:21:53 +0200 Subject: Refactor to improve docs of each function --- src/content/text.rs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/content/text.rs') 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 +/// ^ +/// ``` 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) -- cgit