aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-15 19:44:19 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-15 19:44:19 +0200
commit2ae00fbbf2f88da9163b512b1f1205e18499ab9e (patch)
tree1dd32999327eb29864db0402f4c36213173d8066 /src/compiler.rs
parentb6342221eb3cacda6e893d7d35bf291944c664d9 (diff)
downloadmarkdown-rs-2ae00fbbf2f88da9163b512b1f1205e18499ab9e.tar.gz
markdown-rs-2ae00fbbf2f88da9163b512b1f1205e18499ab9e.tar.bz2
markdown-rs-2ae00fbbf2f88da9163b512b1f1205e18499ab9e.zip
Fix some final eol bugs
Diffstat (limited to 'src/compiler.rs')
-rw-r--r--src/compiler.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler.rs b/src/compiler.rs
index c4178d4..07f0d6b 100644
--- a/src/compiler.rs
+++ b/src/compiler.rs
@@ -451,6 +451,7 @@ pub fn compile(events: &[Event], codes: &[Code], options: &Options) -> String {
let mut exit_map: Map = HashMap::new();
exit_map.insert(Token::AutolinkEmail, on_exit_autolink_email);
exit_map.insert(Token::AutolinkProtocol, on_exit_autolink_protocol);
+ exit_map.insert(Token::BlankLineEnding, on_exit_blank_line_ending);
exit_map.insert(Token::BlockQuote, on_exit_block_quote);
exit_map.insert(Token::CharacterEscapeValue, on_exit_data);
exit_map.insert(
@@ -857,10 +858,18 @@ fn on_exit_break(context: &mut CompileContext) {
context.tag("<br />".to_string());
}
+/// Handle [`Exit`][EventType::Exit]:[`BlankLineEnding`][Token::BlankLineEnding].
+fn on_exit_blank_line_ending(context: &mut CompileContext) {
+ if context.index == context.events.len() - 1 {
+ context.line_ending_if_needed();
+ }
+}
+
/// Handle [`Exit`][EventType::Exit]:[`BlockQuote`][Token::BlockQuote].
fn on_exit_block_quote(context: &mut CompileContext) {
context.tight_stack.pop();
context.line_ending_if_needed();
+ context.slurp_one_line_ending = false;
context.tag("</blockquote>".to_string());
}