|
| 1 | +//! Configuration. |
| 2 | +//! |
| 3 | +//! JS equivalent: https://github.com/syntax-tree/mdast-util-to-markdown/blob/fd6a508/lib/types.js#L307. |
| 4 | +
|
| 5 | +#[derive(Clone, Copy)] |
| 6 | +/// Configuration for indent of lists. |
| 7 | +pub enum IndentOptions { |
| 8 | + /// Depends on the item and its parent list: uses `IndentOptions::One` if |
| 9 | + /// the item and list are tight and `IndentOptions::Tab` otherwise. |
| 10 | + Mixed, |
| 11 | + /// The size of the bullet plus one space. |
| 12 | + One, |
| 13 | + /// Tab stop. |
| 14 | + Tab, |
| 15 | +} |
| 16 | + |
| 17 | +/// Configuration. |
1 | 18 | pub struct Options {
|
2 |
| - /// Marker to use for bullets of items in unordered lists ('*', '+', or '-', default: '*'). |
| 19 | + /// Marker to use for bullets of items in unordered lists (`'*'`, `'+'`, or |
| 20 | + /// `'-'`, default: `'*'`). |
3 | 21 | pub bullet: char,
|
4 |
| - // Marker to use in certain cases where the primary bullet doesn’t work |
5 |
| - // ('*', '+', or '-', default: '-' when bullet is '*', '*' otherwise). |
6 |
| - pub bullet_other: char, |
7 |
| - /// Marker to use for bullets of items in ordered lists ('.' or ')', default: '.'). |
| 22 | + /// Marker to use for bullets of items in ordered lists (`'.'` or `')'`, |
| 23 | + /// default: `'.'`). |
8 | 24 | pub bullet_ordered: char,
|
9 |
| - /// Marker to use for emphasis ('*' or '_', default: '*'). |
| 25 | + /// Marker to use in certain cases where the primary bullet doesn’t work |
| 26 | + /// (`'*'`, `'+'`, or `'-'`, default: `'-'` when bullet is `'*'`, `'*'` |
| 27 | + /// otherwise). |
| 28 | + pub bullet_other: char, |
| 29 | + /// Whether to add the same number of number signs (`#`) at the end of an |
| 30 | + /// ATX heading as the opening sequence (`bool`, default: `false`). |
| 31 | + pub close_atx: bool, |
| 32 | + /// Marker to use for emphasis (`'*'` or `'_'`, default: `'*'`). |
10 | 33 | pub emphasis: char,
|
11 |
| - // Marker to use for fenced code ('`' or '~', default: '`'). |
| 34 | + /// Marker to use for fenced code (``'`'`` or `'~'`, default: ``'`'``). |
12 | 35 | pub fence: char,
|
13 |
| - /// Whether to use fenced code always (bool, default: true). The default is to use fenced code |
14 |
| - /// if there is a language defined, if the code is empty, or if it starts or ends in blank lines. |
| 36 | + /// Whether to use fenced code always (`bool`, default: `true`). |
| 37 | + /// The default is to use fenced code if there is a language defined, |
| 38 | + /// if the code is empty, |
| 39 | + /// or if it starts or ends in blank lines. |
15 | 40 | pub fences: bool,
|
16 |
| - // How to indent the content of list items (default: 'IndentOptions::One'). |
| 41 | + /// Whether to increment the counter of ordered lists items (`bool`, |
| 42 | + /// default: `true`). |
| 43 | + pub increment_list_marker: bool, |
| 44 | + /// How to indent the content of list items (default: `IndentOptions::One`). |
17 | 45 | pub list_item_indent: IndentOptions,
|
18 |
| - /// Marker to use for titles ('"' or "'", default: '"'). |
| 46 | + /// Marker to use for titles (`'"'` or `"'"`, default: `'"'`). |
19 | 47 | pub quote: char,
|
20 |
| - /// Marker to use for thematic breaks ('*', '-', or '_', default: '*'). |
21 |
| - pub rule: char, |
22 |
| - // Marker to use for strong ('*' or '_', default: '*'). |
23 |
| - pub strong: char, |
24 |
| - // Whether to increment the counter of ordered lists items (bool, default: true). |
25 |
| - pub increment_list_marker: bool, |
26 |
| - /// Whether to add the same number of number signs (#) at the end of an ATX heading as the |
27 |
| - /// opening sequence (bool, default: false). |
28 |
| - pub close_atx: bool, |
29 |
| - /// Whether to always use resource links (bool, default: false). The default is to use autolinks |
30 |
| - /// (<https://example.com>) when possible and resource links ([text](url)) otherwise. |
| 48 | + /// Whether to always use resource links (`bool`, default: `false`). |
| 49 | + /// The default is to use autolinks (`<https://example.com>`) when possible |
| 50 | + /// and resource links (`[text](url)`) otherwise. |
31 | 51 | pub resource_link: bool,
|
32 |
| - /// Whether to add spaces between markers in thematic breaks (bool, default: false). |
| 52 | + /// Marker to use for thematic breaks (`'*'`, `'-'`, or `'_'`, default: |
| 53 | + /// `'*'`). |
| 54 | + pub rule: char, |
| 55 | + /// Number of markers to use for thematic breaks (`u32`, default: `3`, min: |
| 56 | + /// `3`). |
| 57 | + pub rule_repetition: u32, |
| 58 | + /// Whether to add spaces between markers in thematic breaks (`bool`, |
| 59 | + /// default: `false`). |
33 | 60 | pub rule_spaces: bool,
|
34 |
| - /// Whether to use setext headings when possible (bool, default: false). The default is to always |
35 |
| - /// use ATX headings (# heading) instead of setext headings (heading\n=======). Setext headings |
36 |
| - /// cannot be used for empty headings or headings with a rank of three or more. |
| 61 | + /// Whether to use setext headings when possible (`bool`, default: |
| 62 | + /// `false`). |
| 63 | + /// The default is to always use ATX headings (`# heading`) instead of |
| 64 | + /// setext headings (`heading\n=======`). |
| 65 | + /// Setext headings cannot be used for empty headings or headings with a |
| 66 | + /// rank of three or more. |
37 | 67 | pub setext: bool,
|
38 |
| - /// Whether to join definitions without a blank line (bool, default: false). |
| 68 | + /// Marker to use for strong (`'*'` or `'_'`, default: `'*'`). |
| 69 | + pub strong: char, |
| 70 | + /// Whether to join definitions without a blank line (`bool`, default: |
| 71 | + /// `false`). |
39 | 72 | pub tight_definitions: bool,
|
40 |
| - // Number of markers to use for thematic breaks (u32, default: 3, min: 3). |
41 |
| - pub rule_repetition: u32, |
42 |
| -} |
43 |
| - |
44 |
| -#[derive(Copy, Clone)] |
45 |
| -pub enum IndentOptions { |
46 |
| - // Depends on the item and its parent list uses 'One' if the item and list are tight and 'Tab' |
47 |
| - // otherwise. |
48 |
| - Mixed, |
49 |
| - // The size of the bullet plus one space. |
50 |
| - One, |
51 |
| - /// Tab stop. |
52 |
| - Tab, |
53 | 73 | }
|
54 | 74 |
|
55 | 75 | impl Default for Options {
|
56 | 76 | fn default() -> Self {
|
57 | 77 | Self {
|
58 | 78 | bullet: '*',
|
59 |
| - bullet_other: '-', |
60 | 79 | bullet_ordered: '.',
|
| 80 | + bullet_other: '-', |
| 81 | + close_atx: false, |
61 | 82 | emphasis: '*',
|
62 | 83 | fence: '`',
|
63 | 84 | fences: true,
|
64 | 85 | increment_list_marker: true,
|
65 |
| - rule_repetition: 3, |
66 | 86 | list_item_indent: IndentOptions::One,
|
67 | 87 | quote: '"',
|
| 88 | + resource_link: false, |
68 | 89 | rule: '*',
|
69 |
| - strong: '*', |
70 |
| - close_atx: false, |
| 90 | + rule_repetition: 3, |
71 | 91 | rule_spaces: false,
|
72 |
| - resource_link: false, |
73 | 92 | setext: false,
|
| 93 | + strong: '*', |
74 | 94 | tight_definitions: false,
|
75 | 95 | }
|
76 | 96 | }
|
|
0 commit comments