Revert "block: override roman list with alpha if encountered"

This reverts commit 7bdccbef65cf76da4cffaa3cac9b3f139f945036.
This commit is contained in:
Noah Hellman 2023-01-24 17:50:21 +01:00
parent 5714e72939
commit 50287ca9da

View file

@ -112,21 +112,6 @@ struct OpenList {
node: tree::NodeIndex,
}
impl ListType {
fn compatible(self, other: Self) -> bool {
self == other
|| if let (Self::Ordered(n0, s0), Self::Ordered(n1, s1)) = (self, other) {
s0 == s1
&& (matches!((n0, n1), (AlphaLower, RomanLower))
|| matches!((n0, n1), (RomanLower, AlphaLower))
|| matches!((n0, n1), (RomanUpper, AlphaUpper))
|| matches!((n0, n1), (AlphaLower, RomanLower)))
} else {
false
}
}
}
/// Parser for block-level tree structure of entire document.
struct TreeParser<'s> {
src: &'s str,
@ -199,12 +184,12 @@ impl<'s> TreeParser<'s> {
};
// close list if a non list item or a list item of new type appeared
if let Some(OpenList { ty, depth, node }) = self.open_lists.last() {
if let Some(OpenList { ty, depth, .. }) = self.open_lists.last() {
assert!(usize::from(*depth) <= self.tree.depth());
if self.tree.depth() == (*depth).into()
&& !matches!(
kind,
Block::Container(Container::ListItem(ty_new)) if ty.compatible(ty_new),
Block::Container(Container::ListItem(ty_new)) if *ty == ty_new,
)
{
self.tree.exit(); // list
@ -308,20 +293,6 @@ impl<'s> TreeParser<'s> {
depth: self.tree.depth().try_into().unwrap(),
node,
});
} else if let ListType::Ordered(n @ (AlphaLower | AlphaUpper), _) = ty {
if let Some(OpenList { node, .. }) = self.open_lists.last() {
if let tree::Element::Container(Node::Container(
Container::List {
ty: ListType::Ordered(numbering, _),
..
},
)) = self.tree.elem_mut(*node)
{
*numbering = n;
} else {
panic!();
}
}
}
}