17 lines
413 B
Rust
17 lines
413 B
Rust
|
use pulldown_cmark::{Event, Parser};
|
||
|
|
||
|
pub fn remove_markdown(markdown: &str) -> String {
|
||
|
let mut out = String::new();
|
||
|
let parser = Parser::new(markdown);
|
||
|
|
||
|
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'),
|
||
|
_ => {}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
out
|
||
|
}
|