diff --git a/crates/story/examples/html.html b/crates/story/examples/html.html index 7452b52a..3f6de6ea 100644 --- a/crates/story/examples/html.html +++ b/crates/story/examples/html.html @@ -10,6 +10,12 @@ >, bold, italic, and code text.

+

This is a text before blockquote.

+
+ This is before paragraph in blockquote. +

This is a second blockquote paragraph.

+

This is after paragraph in blockquote.

+

div() - .children({ - let children_len = children.len(); - - children.into_iter().enumerate().map(move |(ix, c)| { - let is_last_child = ix == children_len - 1; - c.render(None, is_last_child, text_view_style, window, cx) + .children( + children.into_iter().map(move |c| { + c.render(None, false, text_view_style, window, cx) }) - }) + ) .into_any_element(), Node::Paragraph(paragraph) => div().mb(mb).child(paragraph).into_any_element(), Node::Heading { level, children } => { diff --git a/crates/ui/src/text/html.rs b/crates/ui/src/text/html.rs index bd97eabc..ed26a1c8 100644 --- a/crates/ui/src/text/html.rs +++ b/crates/ui/src/text/html.rs @@ -499,6 +499,7 @@ fn parse_paragraph( title: title.map(Into::into), }); } + _ => { // All unknown tags to as text let mut child_paragraph = Paragraph::default(); @@ -697,6 +698,24 @@ fn parse_node(node: &Rc, paragraph: &mut Paragraph) -> element::Node { table } } + local_name!("blockquote") => { + let mut children = vec![]; + if !paragraph.is_empty() { + children.push(element::Node::Paragraph(paragraph.clone())); + paragraph.clear(); + } + + let mut blockquote = Paragraph::default(); + for (i, child) in node.children.borrow().iter().enumerate() { + if i > 0 { + blockquote.push_str("\n"); + } + parse_paragraph(&mut blockquote, child); + } + children.push(element::Node::Blockquote(blockquote)); + + element::Node::Root { children: children } + } _ => { if BLOCK_ELEMENTS.contains(&name.local.trim()) { let mut children: Vec = vec![];