ctb_formats_html/
text_decorator.rs1#[allow(
23 unused_imports,
24 clippy::wildcard_imports,
25 reason = "Standard workspace module prelude"
26)]
27use crate::utilities::*;
28
29#[derive(Clone, Debug, Default)]
32pub struct PlainTextDecorator;
33
34impl PlainTextDecorator {
35 #[must_use]
37 pub fn new() -> Self {
38 Self
39 }
40}
41
42impl html2text::render::TextDecorator for PlainTextDecorator {
43 type Annotation = ();
44
45 fn decorate_link_start(
46 &mut self,
47 _url: &str,
48 ) -> (String, Self::Annotation) {
49 (String::new(), ())
50 }
51
52 fn decorate_link_end(&mut self) -> String {
53 String::new()
54 }
55
56 fn decorate_em_start(&self) -> (String, Self::Annotation) {
57 (String::new(), ())
58 }
59
60 fn decorate_em_end(&self) -> String {
61 String::new()
62 }
63
64 fn decorate_strong_start(&self) -> (String, Self::Annotation) {
65 (String::new(), ())
66 }
67
68 fn decorate_strong_end(&self) -> String {
69 String::new()
70 }
71
72 fn decorate_strikeout_start(&self) -> (String, Self::Annotation) {
73 (String::new(), ())
74 }
75
76 fn decorate_strikeout_end(&self) -> String {
77 String::new()
78 }
79
80 fn decorate_code_start(&self) -> (String, Self::Annotation) {
81 (String::new(), ())
82 }
83
84 fn decorate_code_end(&self) -> String {
85 String::new()
86 }
87
88 fn decorate_preformat_first(&self) -> Self::Annotation {}
89
90 fn decorate_preformat_cont(&self) -> Self::Annotation {}
91
92 fn decorate_image(
93 &mut self,
94 _src: &str,
95 title: &str,
96 ) -> (String, Self::Annotation) {
97 (title.to_string(), ())
98 }
99
100 fn header_prefix(&self, level: usize) -> String {
101 let mut s = String::new();
102 for _ in 0..level {
103 s.push('#');
104 }
105 s.push(' ');
106 s
107 }
108
109 fn quote_prefix(&self) -> String {
110 "> ".to_string()
111 }
112
113 fn unordered_item_prefix(&self) -> String {
114 "* ".to_string()
115 }
116
117 fn ordered_item_prefix(&self, i: i64) -> String {
118 format!("{i}. ")
119 }
120
121 fn make_subblock_decorator(&self) -> Self {
122 self.clone()
123 }
124}