Skip to main content

rhwp/doclang/ir/
style.rs

1/// Six character-level formatting flags that DocLang expresses directly.
2///
3/// All six correspond 1-to-1 with rhwp `CharShape` booleans and with DocLang
4/// inline elements `<bold>`, `<italic>`, `<underline>`, `<strikethrough>`,
5/// `<superscript>`, and `<subscript>`.
6#[derive(Debug, Clone, Copy, PartialEq, Default)]
7pub struct StyleFlags {
8    pub bold: bool,
9    pub italic: bool,
10    pub underline: bool,
11    pub strike: bool,
12    pub superscript: bool,
13    pub subscript: bool,
14}
15
16impl StyleFlags {
17    /// Returns `true` when no flag is set (plain text run).
18    pub fn is_plain(&self) -> bool {
19        !self.bold
20            && !self.italic
21            && !self.underline
22            && !self.strike
23            && !self.superscript
24            && !self.subscript
25    }
26}
27
28/// HWP-specific properties that have no direct DocLang v0.6 representation.
29///
30/// Populated during adapter lowering.  In `Lean` mode the fields are included
31/// in the `LossReport`; in `Preserve` mode they are serialised as
32/// `<custom ns="hwp:style">` payload.
33///
34/// All fields are optional — only the subset actually present in the source
35/// paragraph or character shape is filled in.
36#[derive(Debug, Clone, PartialEq, Default)]
37pub struct LostProperties {
38    /// Named paragraph style (e.g. "본문", "제목1").
39    pub named_style: Option<String>,
40    /// Font name (may vary by script; this stores the Latin/default face).
41    pub font_name: Option<String>,
42    /// Font size in tenth-points (HWP internal unit), e.g. 100 = 10 pt.
43    pub font_size: Option<i32>,
44    /// Text foreground color as 0xRRGGBB.
45    pub text_color: Option<u32>,
46    /// Section-level information (column layout, page margins, etc.) serialised
47    /// as an opaque JSON-like string for preserve mode.
48    pub section_info: Option<String>,
49    /// Catch-all for any other HWP properties not covered by the typed fields
50    /// above.  Stored as `(key, value)` pairs where both strings are
51    /// human-readable / round-trip safe.
52    pub extras: Vec<(String, String)>,
53}