diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-09-05 15:03:24 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-09-05 15:03:24 +0200 |
commit | 3d00bf57a225369120fd98bee36f65a541260da1 (patch) | |
tree | 65780bdbc880f06ba3c92d8c5dbddbdd00ccb92e /src/construct/text.rs | |
parent | 16de10fe2395002644d685fdfcf76823346d1cc4 (diff) | |
download | markdown-rs-3d00bf57a225369120fd98bee36f65a541260da1.tar.gz markdown-rs-3d00bf57a225369120fd98bee36f65a541260da1.tar.bz2 markdown-rs-3d00bf57a225369120fd98bee36f65a541260da1.zip |
Fix to implement GFM autolink literals exactly
Diffstat (limited to 'src/construct/text.rs')
-rw-r--r-- | src/construct/text.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/construct/text.rs b/src/construct/text.rs index 3cb0f10..0168d02 100644 --- a/src/construct/text.rs +++ b/src/construct/text.rs @@ -29,17 +29,21 @@ use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; /// Characters that can start something in text. -const MARKERS: [u8; 11] = [ +const MARKERS: [u8; 15] = [ b'!', // `label_start_image` b'$', // `raw_text` (math (text)) b'&', // `character_reference` b'*', // `attention` (emphasis, strong) b'<', // `autolink`, `html_text` + b'H', // `gfm_autolink_literal` (`protocol` kind) + b'W', // `gfm_autolink_literal` (`www.` kind) b'[', // `label_start_link` b'\\', // `character_escape`, `hard_break_escape` b']', // `label_end`, `gfm_label_start_footnote` b'_', // `attention` (emphasis, strong) b'`', // `raw_text` (code (text)) + b'h', // `gfm_autolink_literal` (`protocol` kind) + b'w', // `gfm_autolink_literal` (`www.` kind) b'~', // `attention` (gfm strikethrough) ]; @@ -113,6 +117,20 @@ pub fn before(tokenizer: &mut Tokenizer) -> State { ); State::Retry(StateName::AutolinkStart) } + Some(b'H' | b'h') => { + tokenizer.attempt( + State::Next(StateName::TextBefore), + State::Next(StateName::TextBeforeData), + ); + State::Retry(StateName::GfmAutolinkLiteralProtocolStart) + } + Some(b'W' | b'w') => { + tokenizer.attempt( + State::Next(StateName::TextBefore), + State::Next(StateName::TextBeforeData), + ); + State::Retry(StateName::GfmAutolinkLiteralWwwStart) + } Some(b'[') => { tokenizer.attempt( State::Next(StateName::TextBefore), |