Fix parsing of ordered lists

feature/epub-rendering
trivernis 4 years ago
parent 4cce555310
commit 2f85961b65

2
Cargo.lock generated

@ -1117,7 +1117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "snekdown"
version = "0.22.2"
version = "0.22.3"
dependencies = [
"asciimath-rs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",

@ -1,6 +1,6 @@
[package]
name = "snekdown"
version = "0.22.2"
version = "0.22.3"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"
license-file = "LICENSE"

@ -213,11 +213,7 @@ impl ParseBlock for Parser {
let start_index = self.ctm.get_index();
self.ctm.seek_whitespace();
let ordered = if self.ctm.check_any(&LIST_SPECIAL_CHARS) {
false
} else {
true
};
let ordered = self.ctm.get_current().is_numeric();
list.ordered = ordered;
let mut list_hierarchy: Vec<ListItem> = Vec::new();
while let Ok(mut item) = self.parse_list_item() {

@ -58,10 +58,14 @@ impl ParseLine for Parser {
.assert_any(&LIST_SPECIAL_CHARS, Some(start_index))?;
let ordered = self.ctm.get_current().is_numeric();
self.ctm.seek_one()?;
if self.ctm.check_char(&DOT) {
if ordered {
while self.ctm.get_current().is_numeric() {
self.ctm.seek_one()?;
}
self.ctm.assert_char(&DOT, Some(start_index))?;
self.ctm.seek_one()?;
}
if !self.ctm.check_any(&INLINE_WHITESPACE) {
return Err(self.ctm.rewind_with_error(start_index));
}

Loading…
Cancel
Save