use maudit::content::markdown::components::*; // Custom heading component that adds icons and anchor links pub struct CustomHeading; impl HeadingComponent for CustomHeading { fn render_start(&self, level: u8, id: Option<&str>, classes: &[&str]) -> String { let id_attr = id.map(|i| format!(" id=\"{}\"", i)).unwrap_or_default(); let class_attr = if classes.is_empty() { String::new() } else { format!(" class=\"{}\"", classes.join(" ")) }; let icon = match level { 1 => "đŸŽ¯", 2 => "📌", 3 => "⭐", 4 => "🔹", 5 => "🔸", 6 => "💎", _ => "🔷", }; format!("{icon} ") } fn render_end(&self, level: u8) -> String { format!("") } } // Custom paragraph with fancy styling pub struct CustomParagraph; impl ParagraphComponent for CustomParagraph { fn render_start(&self) -> String { "

".to_string() } fn render_end(&self) -> String { "

".to_string() } } // Custom link with external link detection pub struct CustomLink; impl LinkComponent for CustomLink { fn render_start(&self, url: &str, title: Option<&str>, _link_type: LinkType) -> String { let title_attr = title .map(|t| format!(" title=\"{}\"", t)) .unwrap_or_default(); let class = if url.starts_with("http") { "external-link" } else { "internal-link" }; format!("", url, class, title_attr) } fn render_end(&self) -> String { "".to_string() } } // Custom image with figure wrapper pub struct CustomImage; impl ImageComponent for CustomImage { fn render(&self, url: &str, alt: &str, title: Option<&str>) -> String { let title_attr = title .map(|t| format!(" title=\"{}\"", t)) .unwrap_or_default(); format!( "
\"{}\"
{}
", url, alt, title_attr, title.unwrap_or_default() ) } } // Custom strong with gradient text pub struct CustomStrong; impl StrongComponent for CustomStrong { fn render_start(&self) -> String { "".to_string() } fn render_end(&self) -> String { "".to_string() } } // Custom emphasis with italic styling pub struct CustomEmphasis; impl EmphasisComponent for CustomEmphasis { fn render_start(&self) -> String { "".to_string() } fn render_end(&self) -> String { "".to_string() } } // Custom inline code with syntax highlighting pub struct CustomCode; impl CodeComponent for CustomCode { fn render(&self, code: &str) -> String { format!("{}", code) } } // Custom blockquote with different styles per type pub struct CustomBlockquote; impl BlockquoteComponent for CustomBlockquote { fn render_start(&self, kind: Option) -> String { match kind { Some(BlockQuoteKind::Note) => "
â„šī¸
".to_string(), Some(BlockQuoteKind::Tip) => "
💡
".to_string(), Some(BlockQuoteKind::Warning) => "
âš ī¸
".to_string(), Some(BlockQuoteKind::Important) => "
❗
".to_string(), Some(BlockQuoteKind::Caution) => "
🚨
".to_string(), None => "
".to_string(), } } fn render_end(&self, kind: Option) -> String { if kind.is_some() { "
".to_string() } else { "
".to_string() } } } // Custom hard break pub struct CustomHardBreak; impl HardBreakComponent for CustomHardBreak { fn render(&self) -> String { "
".to_string() } } // Custom horizontal rule pub struct CustomHorizontalRule; impl HorizontalRuleComponent for CustomHorizontalRule { fn render(&self) -> String { "
".to_string() } } // Custom list with different styling pub struct CustomList; impl ListComponent for CustomList { fn render_start(&self, list_type: ListType, start_number: Option) -> String { match list_type { ListType::Ordered => { let start_attr = start_number .map(|n| format!(" start=\"{}\"", n)) .unwrap_or_default(); format!("
    ", start_attr) } ListType::Unordered => { "
      ".to_string() } } } fn render_end(&self, list_type: ListType) -> String { match list_type { ListType::Ordered => "
".to_string(), ListType::Unordered => "".to_string(), } } } // Custom list item pub struct CustomListItem; impl ListItemComponent for CustomListItem { fn render_start(&self) -> String { "
  • ".to_string() } fn render_end(&self) -> String { "
  • ".to_string() } } // Custom strikethrough pub struct CustomStrikethrough; impl StrikethroughComponent for CustomStrikethrough { fn render_start(&self) -> String { "".to_string() } fn render_end(&self) -> String { "".to_string() } } // Custom task list marker pub struct CustomTaskListMarker; impl TaskListMarkerComponent for CustomTaskListMarker { fn render(&self, checked: bool) -> String { if checked { "".to_string() } else { "".to_string() } } } // Custom table pub struct CustomTable; impl TableComponent for CustomTable { fn render_start(&self, _alignments: &[TableAlignment]) -> String { "".to_string() } fn render_end(&self) -> String { "
    ".to_string() } } // Custom table head pub struct CustomTableHead; impl TableHeadComponent for CustomTableHead { fn render_start(&self) -> String { "".to_string() } fn render_end(&self) -> String { "".to_string() } } // Custom table row pub struct CustomTableRow; impl TableRowComponent for CustomTableRow { fn render_start(&self) -> String { "".to_string() } fn render_end(&self) -> String { "".to_string() } } // Custom table cell pub struct CustomTableCell; impl TableCellComponent for CustomTableCell { fn render_start(&self, is_header: bool, alignment: Option) -> String { let tag = if is_header { "th" } else { "td" }; let mut class = "table-cell".to_string(); match alignment { Some(TableAlignment::Center) => class.push_str(" center"), Some(TableAlignment::Right) => class.push_str(" right"), _ => {} }; format!("<{} class=\"{}\">", tag, class) } fn render_end(&self, is_header: bool) -> String { let tag = if is_header { "th" } else { "td" }; format!("", tag) } }