honor content_format clientcap

This removes all markdown when the client does not support the markdown MarkupKind

Otherwise the output on the editor will have some markdown boilerplate, making it less readable
This commit is contained in:
Robin van Dijk 2020-10-05 19:27:29 +02:00
parent e5f252ade7
commit c3cc361294
5 changed files with 74 additions and 9 deletions

View file

@ -0,0 +1,16 @@
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
}