fix(validate): allow empty ListItem (#11)

This commit is contained in:
PoiScript 2020-05-06 11:01:44 +08:00
parent 8fb6e90f57
commit 923343a076
2 changed files with 26 additions and 3 deletions

View file

@ -188,11 +188,13 @@ impl Org<'_> {
| Element::Italic | Element::Italic
| Element::Underline | Element::Underline
| Element::Strike | Element::Strike
| Element::DynBlock(_) | Element::DynBlock(_) => {
| Element::ListItem(_) => {
expect_children!(node_id); expect_children!(node_id);
} }
Element::Drawer(_) | Element::TableCell(_) | Element::Table(_) => (), Element::ListItem(_)
| Element::Drawer(_)
| Element::TableCell(_)
| Element::Table(_) => (),
} }
} }
errors errors

21
tests/issue_11.rs Normal file
View file

@ -0,0 +1,21 @@
use orgize::Org;
#[test]
fn can_handle_empty_list_item() {
let cases = &[
"0. ",
"* \n0. ",
" * ",
" 0. ",
"\t* ",
"- ",
"- hello\n- ",
"- \n- hello",
"- hello\n- \n- world",
"* world\n- ",
];
for case in cases {
let _ = Org::parse(case);
}
}