diff options
author | Robin van Dijk <[email protected]> | 2020-10-05 18:27:29 +0100 |
---|---|---|
committer | Robin van Dijk <[email protected]> | 2020-10-05 18:27:29 +0100 |
commit | c3cc3612948be235577ccfd55990062829c8cfbb (patch) | |
tree | aa9b61453868c37d784e12dde6a7d28d0188969b /crates/ide/src/markdown_remove.rs | |
parent | e5f252ade72fee4776396122dc91a17ddc185a66 (diff) |
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
Diffstat (limited to 'crates/ide/src/markdown_remove.rs')
-rw-r--r-- | crates/ide/src/markdown_remove.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/ide/src/markdown_remove.rs b/crates/ide/src/markdown_remove.rs new file mode 100644 index 000000000..62b2aa1e7 --- /dev/null +++ b/crates/ide/src/markdown_remove.rs | |||
@@ -0,0 +1,16 @@ | |||
1 | use pulldown_cmark::{Event, Parser}; | ||
2 | |||
3 | pub fn remove_markdown(markdown: &str) -> String { | ||
4 | let mut out = String::new(); | ||
5 | let parser = Parser::new(markdown); | ||
6 | |||
7 | for event in parser { | ||
8 | match event { | ||
9 | Event::Text(text) | Event::Code(text) => out.push_str(&text), | ||
10 | Event::SoftBreak | Event::HardBreak | Event::Rule => out.push('\n'), | ||
11 | _ => {} | ||
12 | } | ||
13 | } | ||
14 | |||
15 | out | ||
16 | } | ||