1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#[cfg(feature = "markdown")]
pub mod markdown;
use crate::theme::Style;
use crate::utils::span::{IndexedSpan, Span, SpannedString};
pub type StyledString = SpannedString<Style>;
pub type StyledIndexedSpan = IndexedSpan<Style>;
pub type StyledSpan<'a> = Span<'a, Style>;
impl SpannedString<Style> {
pub fn plain<S>(content: S) -> Self
where
S: Into<String>,
{
Self::styled(content, Style::none())
}
pub fn styled<S, T>(content: S, style: T) -> Self
where
S: Into<String>,
T: Into<Style>,
{
let content = content.into();
let style = style.into();
Self::single_span(content, style)
}
pub fn append_plain<S>(&mut self, text: S)
where
S: Into<String>,
{
self.append(Self::plain(text));
}
pub fn append_styled<S, T>(&mut self, text: S, style: T)
where
S: Into<String>,
T: Into<Style>,
{
self.append(Self::styled(text, style));
}
}