Compare plain list item pre blank.

This commit is contained in:
Tom Alexander
2023-09-29 19:30:02 -04:00
parent 7727b5ef47
commit 064a4eeee7
4 changed files with 26 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ use crate::types::Object;
use crate::types::PlainList;
use crate::types::PlainListItem;
use crate::types::PlainListItemCounter;
use crate::types::PlainListItemPreBlank;
use crate::types::PlainListType;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
@@ -220,6 +221,7 @@ fn plain_list_item<'b, 'g, 'r, 's>(
tag: maybe_tag
.map(|(_ws, item_tag)| item_tag)
.unwrap_or(Vec::new()),
pre_blank: 0,
children: Vec::new(),
},
),
@@ -227,7 +229,11 @@ fn plain_list_item<'b, 'g, 'r, 's>(
}
Err(_) => {}
};
let (remaining, _ws) = item_tag_post_gap(&parser_context, remaining)?;
let (remaining, pre_blank) = item_tag_post_gap(&parser_context, remaining)?;
let pre_blank = Into::<&str>::into(pre_blank)
.bytes()
.filter(|b| *b == b'\n')
.count();
let (mut remaining, (mut children, _exit_contents)) = many_till(
include_input(parser_with_context!(element(true))(&parser_context)),
@@ -266,6 +272,8 @@ fn plain_list_item<'b, 'g, 'r, 's>(
tag: maybe_tag
.map(|(_ws, item_tag)| item_tag)
.unwrap_or(Vec::new()),
pre_blank: PlainListItemPreBlank::try_from(pre_blank)
.expect("pre-blank cannot be larger than 2."),
children: children.into_iter().map(|(_start, item)| item).collect(),
},
),