From db2e39cf62ba9ee72d749dc1a0620e094d609ea6 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 22 Jul 2025 12:53:08 -0400 Subject: [PATCH] parse markdown in this lib --- src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2e5ee8f..46ff9da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ use scraper::{ElementRef, Html, Node}; +use iced::widget::markdown; /* The goal here is to flatten the DOM as much as possible. @@ -9,6 +10,7 @@ use scraper::{ElementRef, Html, Node}; #[derive(Debug,Clone)] pub enum Content { Markdown(String), + MarkdownParsed(Vec), Image(String), Audio(String), Video(String), @@ -16,8 +18,14 @@ pub enum Content { } pub fn parse_content(c: &str) -> Vec{ - - process_content(itemize_content(c)) + process_content(itemize_content(c)).into_iter().map(|i| { + match i { + Content::Markdown(s) => { + Content::MarkdownParsed(markdown::parse(&s).collect()) + } + _ => {i} + } + }).collect() } fn markdownify_child(item: &Item) -> String {