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]] [[package]]
name = "snekdown" name = "snekdown"
version = "0.22.2" version = "0.22.3"
dependencies = [ dependencies = [
"asciimath-rs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",

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

@ -213,11 +213,7 @@ impl ParseBlock for Parser {
let start_index = self.ctm.get_index(); let start_index = self.ctm.get_index();
self.ctm.seek_whitespace(); self.ctm.seek_whitespace();
let ordered = if self.ctm.check_any(&LIST_SPECIAL_CHARS) { let ordered = self.ctm.get_current().is_numeric();
false
} else {
true
};
list.ordered = ordered; list.ordered = ordered;
let mut list_hierarchy: Vec<ListItem> = Vec::new(); let mut list_hierarchy: Vec<ListItem> = Vec::new();
while let Ok(mut item) = self.parse_list_item() { 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))?; .assert_any(&LIST_SPECIAL_CHARS, Some(start_index))?;
let ordered = self.ctm.get_current().is_numeric(); let ordered = self.ctm.get_current().is_numeric();
self.ctm.seek_one()?; self.ctm.seek_one()?;
if ordered {
if self.ctm.check_char(&DOT) { while self.ctm.get_current().is_numeric() {
self.ctm.seek_one()?;
}
self.ctm.assert_char(&DOT, Some(start_index))?;
self.ctm.seek_one()?; self.ctm.seek_one()?;
} }
if !self.ctm.check_any(&INLINE_WHITESPACE) { if !self.ctm.check_any(&INLINE_WHITESPACE) {
return Err(self.ctm.rewind_with_error(start_index)); return Err(self.ctm.rewind_with_error(start_index));
} }

Loading…
Cancel
Save