mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
add break after codeblocks
This commit is contained in:
parent
bc890ed5b0
commit
bd7bf4a276
1 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
//! Removes markdown from strings.
|
//! Removes markdown from strings.
|
||||||
|
|
||||||
use pulldown_cmark::{Event, Parser};
|
use pulldown_cmark::{Event, Parser, Tag};
|
||||||
|
|
||||||
/// Removes all markdown, keeping the text and code blocks
|
/// Removes all markdown, keeping the text and code blocks
|
||||||
///
|
///
|
||||||
|
@ -12,7 +12,9 @@ pub fn remove_markdown(markdown: &str) -> String {
|
||||||
for event in parser {
|
for event in parser {
|
||||||
match event {
|
match event {
|
||||||
Event::Text(text) | Event::Code(text) => out.push_str(&text),
|
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')
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue