Fix block documents being ignored at EOF

Fixes that block elements are being ignored when written as the last
element of a file (Fixes #14)x

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/15/head
trivernis 4 years ago
parent 8cf6dd33b7
commit e99b80ecf0
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

4
Cargo.lock generated

@ -235,9 +235,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "charred" name = "charred"
version = "0.3.4" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d76bd26a00789c7e782d3ba5c0adae6f7eabc2a1026dfb41838b0e11ebf55f8" checksum = "ed9759715d56a062d5636cd0cbc71f2aa8a978afe08c572a69e65e8cf53418f5"
[[package]] [[package]]
name = "chrono" name = "chrono"

@ -21,7 +21,7 @@ path = "src/main.rs"
pdf = ["headless_chrome", "failure"] pdf = ["headless_chrome", "failure"]
[dependencies] [dependencies]
charred = "0.3.4" charred = "0.3.5"
asciimath-rs = "0.5.7" asciimath-rs = "0.5.7"
bibliographix = "0.6.0" bibliographix = "0.6.0"
crossbeam-utils = "0.7.2" crossbeam-utils = "0.7.2"

@ -135,8 +135,9 @@ impl ParseBlock for Parser {
let language = self.ctm.get_string_until_any(&[LB], &[])?; let language = self.ctm.get_string_until_any(&[LB], &[])?;
self.ctm.seek_one()?; self.ctm.seek_one()?;
let text = self.ctm.get_string_until_sequence(&[&SQ_CODE_BLOCK], &[])?; let text = self.ctm.get_string_until_sequence(&[&SQ_CODE_BLOCK], &[])?;
for _ in 0..2 { for _ in 0..2 {
self.ctm.seek_one()?; self.ctm.try_seek();
} }
Ok(CodeBlock { Ok(CodeBlock {
@ -153,7 +154,7 @@ impl ParseBlock for Parser {
self.ctm.seek_one()?; self.ctm.seek_one()?;
let text = self.ctm.get_string_until_sequence(&[SQ_MATH], &[])?; let text = self.ctm.get_string_until_sequence(&[SQ_MATH], &[])?;
for _ in 0..1 { for _ in 0..1 {
self.ctm.seek_one()?; self.ctm.try_seek();
} }
Ok(MathBlock { Ok(MathBlock {
expression: asciimath_rs::parse(text), expression: asciimath_rs::parse(text),
@ -231,6 +232,7 @@ impl ParseBlock for Parser {
let ordered = self.ctm.get_current().is_numeric(); let ordered = self.ctm.get_current().is_numeric();
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() {
while let Some(parent_item) = list_hierarchy.pop() { while let Some(parent_item) = list_hierarchy.pop() {
if parent_item.level < item.level { if parent_item.level < item.level {
@ -289,6 +291,7 @@ impl ParseBlock for Parser {
} }
let seek_index = self.ctm.get_index(); let seek_index = self.ctm.get_index();
let mut table = Table::new(header); let mut table = Table::new(header);
while let Ok(_) = self.ctm.seek_one() { while let Ok(_) = self.ctm.seek_one() {
self.ctm.seek_any(&INLINE_WHITESPACE)?; self.ctm.seek_any(&INLINE_WHITESPACE)?;
if !self.ctm.check_any(&[MINUS, PIPE]) || self.ctm.check_char(&LB) { if !self.ctm.check_any(&[MINUS, PIPE]) || self.ctm.check_char(&LB) {

Loading…
Cancel
Save