use pulldown_cmark::Alignment;
use ratatui_core::style::Style;
use ratatui_core::text::{Line, Span};
use crate::term::image::ImageData;
pub(super) const INDENT: u16 = 2;
pub(super) enum MdItem {
Prose { spans: Vec<RichSpan>, indent: u16 },
CodeBlock {
language: String,
source: String,
fallback: Vec<Line<'static>>,
indent: u16,
},
Table { table: TableData, indent: u16 },
Image {
data: ImageData,
alt: String,
indent: u16,
},
Blank,
}
#[derive(Clone, Debug)]
pub(super) struct RichSpan {
pub(super) content: String,
pub(super) style: Style,
pub(super) href: Option<String>,
}
impl RichSpan {
pub(super) fn styled(content: impl Into<String>, style: Style, href: Option<String>) -> Self {
Self {
content: content.into(),
style,
href,
}
}
pub(super) fn to_span(&self) -> Span<'static> {
Span::styled(self.content.clone(), self.style)
}
}
pub(super) struct TableData {
pub(super) aligns: Vec<Alignment>,
pub(super) header: Vec<Cell>,
pub(super) rows: Vec<Vec<Cell>>,
}
pub(super) type Cell = Vec<RichSpan>;