html_auto_p/options.rs
1#[derive(Default, Debug, Clone)]
2/// Options for the `auto_p` function.
3pub struct Options {
4 /// Whether to convert remaining line-breaks to `<br>` elements.
5 pub br: bool,
6 /// Whether to escape the inner HTML in `<pre>` elements. This is useful when the inner HTML needs to be formatted and be wrapped into other non-`<pre>` elements.
7 pub esc_pre: bool,
8 /// Whether to remove useless newlines in the inner HTML of `<pre>` elements. This is useful to beautifully form code into `<pre>\n...\n</pre>` without worrying about the adjacent newlines' effects.
9 pub remove_useless_newlines_in_pre: bool,
10}
11
12impl Options {
13 /// Create default options. (All false)
14 #[inline]
15 pub const fn new() -> Self {
16 Options {
17 br: false,
18 esc_pre: false,
19 remove_useless_newlines_in_pre: false,
20 }
21 }
22
23 /// Set whether to convert remaining line-breaks to `<br>` elements.
24 #[inline]
25 pub const fn br(mut self, br: bool) -> Self {
26 self.br = br;
27
28 self
29 }
30
31 /// Set whether to escape the inner HTML in `<pre>` elements.
32 #[inline]
33 pub const fn esc_pre(mut self, esc_pre: bool) -> Self {
34 self.esc_pre = esc_pre;
35
36 self
37 }
38
39 /// Set whether to remove useless newlines in the inner HTML of `<pre>` elements.
40 #[inline]
41 pub const fn remove_useless_newlines_in_pre(
42 mut self,
43 remove_useless_newlines_in_pre: bool,
44 ) -> Self {
45 self.remove_useless_newlines_in_pre = remove_useless_newlines_in_pre;
46
47 self
48 }
49}