parse markdown in this lib
This commit is contained in:
parent
16bfecb1f8
commit
db2e39cf62
1 changed files with 10 additions and 2 deletions
12
src/lib.rs
12
src/lib.rs
|
@ -1,4 +1,5 @@
|
||||||
use scraper::{ElementRef, Html, Node};
|
use scraper::{ElementRef, Html, Node};
|
||||||
|
use iced::widget::markdown;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The goal here is to flatten the DOM as much as possible.
|
The goal here is to flatten the DOM as much as possible.
|
||||||
|
@ -9,6 +10,7 @@ use scraper::{ElementRef, Html, Node};
|
||||||
#[derive(Debug,Clone)]
|
#[derive(Debug,Clone)]
|
||||||
pub enum Content {
|
pub enum Content {
|
||||||
Markdown(String),
|
Markdown(String),
|
||||||
|
MarkdownParsed(Vec<markdown::Item>),
|
||||||
Image(String),
|
Image(String),
|
||||||
Audio(String),
|
Audio(String),
|
||||||
Video(String),
|
Video(String),
|
||||||
|
@ -16,8 +18,14 @@ pub enum Content {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_content(c: &str) -> Vec<Content>{
|
pub fn parse_content(c: &str) -> Vec<Content>{
|
||||||
|
process_content(itemize_content(c)).into_iter().map(|i| {
|
||||||
process_content(itemize_content(c))
|
match i {
|
||||||
|
Content::Markdown(s) => {
|
||||||
|
Content::MarkdownParsed(markdown::parse(&s).collect())
|
||||||
|
}
|
||||||
|
_ => {i}
|
||||||
|
}
|
||||||
|
}).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn markdownify_child(item: &Item) -> String {
|
fn markdownify_child(item: &Item) -> String {
|
||||||
|
|
Loading…
Reference in a new issue