Skip to content

Commit

Permalink
fixed html extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
rambip committed Nov 8, 2023
1 parent 1a407f4 commit 96042d8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,25 @@ where I: Iterator<Item=(Event<'a>, Range<usize>)>
text
}

fn children_html(&mut self, tag: Tag<'a>) -> Option<String> {
let text = match self.stream.next() {
Some((Event::Html(s), _)) => Some(s.to_string()),
None => None,
_ => panic!("expected html event, got something else")
};

let end_tag = &self.stream.next().expect("this event should be the closing tag").0;
assert!(end_tag == &Event::End(as_closing_tag(&tag)));

text
}

fn render_tag(&mut self, tag: Tag<'a>, range: Range<usize>)
-> Result<View, HtmlError>
{
Ok(match tag.clone() {
Tag::HtmlBlock => {
let child = self.children_text(Tag::HtmlBlock);
let child = self.children_html(Tag::HtmlBlock);
child.map(|raw_html| view!{<div inner_html=raw_html></div>})
.into_view()
}
Expand Down

0 comments on commit 96042d8

Please sign in to comment.