From 1e4c95079cb97b2b02440b21945c6d12741a7d19 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 25 Aug 2022 13:16:45 +0200 Subject: Add support for GFM footnotes --- src/parser.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index afa08ac..62b3e03 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -17,8 +17,10 @@ pub struct ParseState<'a> { pub options: &'a Options, /// List of chars. pub bytes: &'a [u8], - /// Set of defined identifiers. + /// Set of defined definition identifiers. pub definitions: Vec, + /// Set of defined GFM footnote definition identifiers. + pub gfm_footnote_definitions: Vec, } /// Turn a string of markdown into events. @@ -29,6 +31,7 @@ pub fn parse<'a>(value: &'a str, options: &'a Options) -> (Vec, &'a [u8]) options, bytes: value.as_bytes(), definitions: vec![], + gfm_footnote_definitions: vec![], }; let mut tokenizer = Tokenizer::new( @@ -50,7 +53,10 @@ pub fn parse<'a>(value: &'a str, options: &'a Options) -> (Vec, &'a [u8]) let mut events = tokenizer.events; - parse_state.definitions = tokenizer.tokenize_state.definitions; + let footnote = tokenizer.tokenize_state.gfm_footnote_definitions; + let normal = tokenizer.tokenize_state.definitions; + parse_state.gfm_footnote_definitions = footnote; + parse_state.definitions = normal; while !subtokenize(&mut events, &parse_state) {} -- cgit