mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
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:
parent
e5f252ade7
commit
c3cc361294
5 changed files with 74 additions and 9 deletions
16
crates/ide/src/markdown_remove.rs
Normal file
16
crates/ide/src/markdown_remove.rs
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue