markdown_ppp/printer/config.rs
1pub struct Config {
2 pub(crate) width: usize,
3 pub(crate) spaces_before_list_item: usize,
4}
5
6impl Default for Config {
7 fn default() -> Self {
8 Self {
9 width: 80,
10 spaces_before_list_item: 1,
11 }
12 }
13}
14
15impl Config {
16 /// Render document with a given width in characters.
17 pub fn with_width(self, width: usize) -> Self {
18 Self { width, ..self }
19 }
20
21 /// Sets the number of spaces to insert before each list item when rendering the AST to Markdown.
22 ///
23 /// The default is 1 space. According to the GitHub Flavored Markdown specification,
24 /// between 0 and 3 spaces before a list marker are allowed:
25 /// <https://github.github.com/gfm/#lists>
26 ///
27 /// # Parameters
28 ///
29 /// - `spaces`: the number of spaces to insert before each list item (valid range: 0..=3).
30 ///
31 /// # Returns
32 ///
33 /// A new printer config instance with `spaces_before_list_item` set to the specified value.
34 pub fn with_spaces_before_list_item(self, spaces: usize) -> Self {
35 Self {
36 spaces_before_list_item: spaces,
37 ..self
38 }
39 }
40}