1use std::fmt;
7
8use ide_db::impl_empty_upmap_from_ra_fixture;
9
10#[derive(Clone, Default, Debug, Hash, PartialEq, Eq)]
11pub struct Markup {
12 text: String,
13}
14
15impl From<Markup> for String {
16 fn from(markup: Markup) -> Self {
17 markup.text
18 }
19}
20
21impl From<String> for Markup {
22 fn from(text: String) -> Self {
23 Markup { text }
24 }
25}
26
27impl fmt::Display for Markup {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 fmt::Display::fmt(&self.text, f)
30 }
31}
32
33impl Markup {
34 pub fn as_str(&self) -> &str {
35 self.text.as_str()
36 }
37 pub fn fenced_block(contents: impl fmt::Display) -> Markup {
38 format!("```rust\n{contents}\n```").into()
39 }
40 pub fn fenced_block_text(contents: impl fmt::Display) -> Markup {
41 format!("```text\n{contents}\n```").into()
42 }
43}
44
45impl_empty_upmap_from_ra_fixture!(Markup);