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
use serde::{Serialize, Deserialize};
use dprint_core::generate_str_to_from;
use dprint_core::configuration::*;

/// Resolved markdown configuration.
#[derive(Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Configuration {
    pub line_width: u32,
    pub new_line_kind: NewLineKind,
    pub text_wrap: TextWrap,
    pub emphasis_kind: EmphasisKind,
    pub strong_kind: StrongKind,
}

/// Text wrapping possibilities.
#[derive(Clone, PartialEq, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum TextWrap {
    /// Always wraps text.
    Always,
    /// Maintains line breaks (default).
    Maintain,
    /// Never wraps text.
    Never,
}

generate_str_to_from![
    TextWrap,
    [Always, "always"],
    [Maintain, "maintain"],
    [Never, "never"]
];

/// The character to use for emphasis/italics.
#[derive(Clone, PartialEq, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum EmphasisKind {
    /// Uses asterisks (*) for emphasis.
    Asterisks,
    /// Uses underscores (_) for emphasis (default).
    Underscores,
}

generate_str_to_from![
    EmphasisKind,
    [Asterisks, "asterisks"],
    [Underscores, "underscores"]
];

/// The character to use for strong emphasis/bold.
#[derive(Clone, PartialEq, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum StrongKind {
    /// Uses asterisks (**) for strong emphasis (default).
    Asterisks,
    /// Uses underscores (__) for strong emphasis.
    Underscores,
}

generate_str_to_from![
    StrongKind,
    [Asterisks, "asterisks"],
    [Underscores, "underscores"]
];