lazy search for media source

This commit is contained in:
Gabriel 2025-07-22 16:52:58 -04:00
parent 0288aa9a2f
commit 3432fec624

View file

@ -22,6 +22,7 @@ pub fn parse_content(c: &str) -> Vec<Content>{
match i {
Content::Markdown(s) => {
Content::MarkdownParsed(markdown::parse(&s).collect())
//this is super lazy but it works....
}
_ => {i}
}
@ -110,7 +111,42 @@ fn markdown_content(item: &Item) -> Content {
Content::Markdown(markdown)
}
fn media_content(_: &Item) -> Content{
fn get_media_source(children: &Vec<Item>) -> Option<String> {
for c in children {
match c {
Item::Source(src) => {
return Some(src.to_owned());
}
_ => {}
}
}
None
}
fn media_content(item: &Item) -> Content{
match item {
Item::Audio(children) => {
match get_media_source(children) {
Some(s) => {
return Content::Audio(s);
}
None => {
return Content::Markdown("<Audio Element with no source>".to_owned());
}
}
}
Item::Video(children) => {
match get_media_source(children) {
Some(source) => {
return Content::Video(source)
}
None => {
return Content::Markdown("<Video element with no source>".to_owned());
}
}
}
_ => {}
}
Content::Markdown("Media not supported yet".to_owned())
}