aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler.rs10
-rw-r--r--src/construct/heading_atx.rs2
2 files changed, 8 insertions, 4 deletions
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("<pre><code".to_string());
code_fenced_fences_count = Some(0);
}
- TokenType::CodeFencedFenceInfo | TokenType::CodeFencedFenceMeta => {
+ 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)
}