1#[derive(Debug, Clone, Default)]
5pub struct LayoutDocument {
6 pub blocks: Vec<LayoutBlock>,
7}
8
9#[derive(Debug, Clone, PartialEq)]
13pub enum LayoutBlock {
14 Text(TextBlock),
15 Code(CodeLayout),
16 Table(TableLayout),
17 Rule(RuleLayout),
18}
19
20#[derive(Debug, Clone, PartialEq)]
22pub struct TextBlock {
23 pub lines: Vec<LayoutLine>,
24}
25
26#[derive(Debug, Clone, PartialEq)]
28pub struct LayoutLine {
29 pub spans: Vec<LayoutSpan>,
30}
31
32#[derive(Debug, Clone, PartialEq)]
34pub struct LayoutSpan {
35 pub content: String,
36 pub style: SemanticStyle,
37 pub link: Option<LinkTarget>,
38}
39
40#[derive(Debug, Clone, PartialEq, Eq)]
42pub struct LinkTarget {
43 pub url: String,
44}
45
46#[derive(Debug, Clone, PartialEq)]
51pub struct CodeLayout {
52 pub language: Option<String>,
53 pub lines: Vec<String>,
54 pub width: usize,
56}
57
58#[derive(Debug, Clone, PartialEq)]
63pub struct TableLayout {
64 pub lines: Vec<LayoutLine>,
65}
66
67#[derive(Debug, Clone, PartialEq)]
69pub struct RuleLayout {
70 pub width: usize,
71}
72
73#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75pub enum SemanticStyle {
76 Body,
77 Muted,
78
79 Heading1,
80 Heading2,
81 Heading3,
82 Heading4,
83 Heading5,
84 Heading6,
85
86 Strong,
87 Emphasis,
88 Strike,
89
90 InlineCode,
91
92 Link,
93
94 Quote,
95
96 Code,
97
98 Border,
99
100 AlertNote,
101 AlertTip,
102 AlertImportant,
103 AlertWarning,
104 AlertCaution,
105}
106
107impl SemanticStyle {
108 pub fn heading(level: u8) -> Self {
110 match level {
111 1 => Self::Heading1,
112 2 => Self::Heading2,
113 3 => Self::Heading3,
114 4 => Self::Heading4,
115 5 => Self::Heading5,
116 _ => Self::Heading6,
117 }
118 }
119}