For plain list items with a single child that is a paragraph, do not wrap in paragraph html tags.
This is mimicking the behavior from org-mode's HTML exporter.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use super::macros::intermediate;
|
||||
use super::IPlainListSimpleItem;
|
||||
|
||||
use super::IElement;
|
||||
use super::IObject;
|
||||
@@ -26,8 +27,19 @@ intermediate!(
|
||||
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for elem in original.children.iter() {
|
||||
ret.push(IElement::new(intermediate_context.clone(), elem).await?);
|
||||
|
||||
// Special case for list items with only 1 child which is a paragraph. In those cases, the paragraph tags are omitted.
|
||||
if original.children.len() == 1
|
||||
&& let Some(organic::types::Element::Paragraph(paragraph)) =
|
||||
original.children.iter().next()
|
||||
{
|
||||
ret.push(IElement::PlainListSimpleItem(
|
||||
IPlainListSimpleItem::new(intermediate_context.clone(), paragraph).await?,
|
||||
));
|
||||
} else {
|
||||
for elem in original.children.iter() {
|
||||
ret.push(IElement::new(intermediate_context.clone(), elem).await?);
|
||||
}
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user