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
use freya_engine::prelude::*;

use crate::{
    Parse,
    ParseError,
};

impl Parse for TextDecoration {
    fn parse(value: &str) -> Result<Self, ParseError> {
        let mut decoration = TextDecoration::default();
        let values = value.split_ascii_whitespace();

        for val in values {
            decoration.set(
                match val {
                    "underline" => TextDecoration::UNDERLINE,
                    "overline" => TextDecoration::OVERLINE,
                    "line-through" => TextDecoration::LINE_THROUGH,
                    _ => TextDecoration::NO_DECORATION,
                },
                true,
            );
        }

        Ok(decoration)
    }
}

impl Parse for TextDecorationStyle {
    fn parse(value: &str) -> Result<Self, ParseError> {
        Ok(match value {
            "solid" => TextDecorationStyle::Solid,
            "double" => TextDecorationStyle::Double,
            "dotted" => TextDecorationStyle::Dotted,
            "dashed" => TextDecorationStyle::Dashed,
            "wavy" => TextDecorationStyle::Wavy,
            _ => TextDecorationStyle::Solid,
        })
    }
}