]> git.lizzy.rs Git - rust.git/commitdiff
add break after codeblocks
authorRobin van Dijk <robin@robinjint.nl>
Tue, 6 Oct 2020 14:34:38 +0000 (16:34 +0200)
committerRobin van Dijk <robin@robinjint.nl>
Tue, 6 Oct 2020 14:34:38 +0000 (16:34 +0200)
crates/ide/src/markdown_remove.rs

index ea12cf0fc3a47592e2cac1ff853868026c55d3b5..02ad39dfb72346cf41a74f715052d481ae2b9c33 100644 (file)
@@ -1,6 +1,6 @@
 //! Removes markdown from strings.
 
-use pulldown_cmark::{Event, Parser};
+use pulldown_cmark::{Event, Parser, Tag};
 
 /// Removes all markdown, keeping the text and code blocks
 ///
@@ -12,7 +12,9 @@ pub fn remove_markdown(markdown: &str) -> String {
     for event in parser {
         match event {
             Event::Text(text) | Event::Code(text) => out.push_str(&text),
-            Event::SoftBreak | Event::HardBreak | Event::Rule => out.push('\n'),
+            Event::SoftBreak | Event::HardBreak | Event::Rule | Event::End(Tag::CodeBlock(_)) => {
+                out.push('\n')
+            }
             _ => {}
         }
     }