From b150a72975d6e75b96298b3d405afe070271d78b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 15 Jun 2022 19:20:43 +0200 Subject: Add support for text in heading (atx) --- src/compiler.rs | 10 ++++++---- src/construct/heading_atx.rs | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler.rs b/src/compiler.rs index d3d935b..6127231 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -117,7 +117,9 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St buf_tail_mut(buffers).push("
 {
+                TokenType::AtxHeadingText
+                | TokenType::CodeFencedFenceInfo
+                | TokenType::CodeFencedFenceMeta => {
                     buffer(buffers);
                 }
                 TokenType::HtmlFlow => {
@@ -139,7 +141,6 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St
                 | TokenType::AtxHeading
                 | TokenType::AtxHeadingSequence
                 | TokenType::AtxHeadingWhitespace
-                | TokenType::AtxHeadingText
                 | TokenType::LineEnding
                 | TokenType::ThematicBreak
                 | TokenType::ThematicBreakSequence
@@ -297,6 +298,8 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St
                     }
                 }
                 TokenType::AtxHeadingText => {
+                    let result = resume(buffers);
+
                     if let Some(ref buf) = atx_heading_buffer {
                         if !buf.is_empty() {
                             buf_tail_mut(buffers).push(encode(buf));
@@ -306,8 +309,7 @@ pub fn compile(events: &[Event], codes: &[Code], options: &CompileOptions) -> St
                         atx_heading_buffer = Some("".to_string());
                     }
 
-                    let slice = encode(&serialize(codes, &from_exit_event(events, index), false));
-                    buf_tail_mut(buffers).push(slice);
+                    buf_tail_mut(buffers).push(encode(&result));
                 }
                 TokenType::AtxHeading => {
                     let rank = atx_opening_sequence_size
diff --git a/src/construct/heading_atx.rs b/src/construct/heading_atx.rs
index 3be8c99..1a9ed03 100644
--- a/src/construct/heading_atx.rs
+++ b/src/construct/heading_atx.rs
@@ -117,6 +117,7 @@ fn at_break(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
         }
         Code::Char(_) => {
             tokenizer.enter(TokenType::AtxHeadingText);
+            tokenizer.enter(TokenType::ChunkText);
             data(tokenizer, code)
         }
     }
@@ -165,6 +166,7 @@ fn data(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
     match code {
         // Note: `#` for closing sequence must be preceded by whitespace, otherwise it’s just text.
         Code::None | Code::CarriageReturnLineFeed | Code::Char('\t' | '\n' | '\r' | ' ') => {
+            tokenizer.exit(TokenType::ChunkText);
             tokenizer.exit(TokenType::AtxHeadingText);
             at_break(tokenizer, code)
         }
-- 
cgit