#[derive(Debug, Clone, Default)]
pub struct LayoutDocument {
pub blocks: Vec<LayoutBlock>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum LayoutBlock {
Text(TextBlock),
Code(CodeLayout),
Table(TableLayout),
Rule(RuleLayout),
}
#[derive(Debug, Clone, PartialEq)]
pub struct TextBlock {
pub lines: Vec<LayoutLine>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct LayoutLine {
pub spans: Vec<LayoutSpan>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct LayoutSpan {
pub content: String,
pub style: SemanticStyle,
pub link: Option<LinkTarget>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LinkTarget {
pub url: String,
}
#[derive(Debug, Clone, PartialEq)]
pub struct CodeLayout {
pub language: Option<String>,
pub lines: Vec<String>,
pub width: usize,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TableLayout {
pub lines: Vec<LayoutLine>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct RuleLayout {
pub width: usize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SemanticStyle {
Body,
Muted,
Heading1,
Heading2,
Heading3,
Heading4,
Heading5,
Heading6,
Strong,
Emphasis,
Strike,
InlineCode,
Link,
Quote,
Code,
Border,
AlertNote,
AlertTip,
AlertImportant,
AlertWarning,
AlertCaution,
}
impl SemanticStyle {
pub fn heading(level: u8) -> Self {
match level {
1 => Self::Heading1,
2 => Self::Heading2,
3 => Self::Heading3,
4 => Self::Heading4,
5 => Self::Heading5,
_ => Self::Heading6,
}
}
}