Implement the new fields for paragraph.

This commit is contained in:
Tom Alexander
2023-10-31 23:06:43 -04:00
parent 92d15c3d91
commit 281c35677b
3 changed files with 22 additions and 11 deletions

View File

@@ -74,7 +74,7 @@ fn anonymous_footnote<'b, 'g, 'r, 's>(
let (remaining, _) = tag("]")(remaining)?;
let (remaining, _trailing_whitespace) =
let (remaining, post_blank) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
Ok((
@@ -82,7 +82,7 @@ fn anonymous_footnote<'b, 'g, 'r, 's>(
FootnoteReference {
source: source.into(),
contents: Some(contents.into()),
post_blank: _trailing_whitespace.map(Into::<&str>::into),
post_blank: post_blank.map(Into::<&str>::into),
label: None,
definition: children,
},
@@ -123,7 +123,7 @@ fn inline_footnote<'b, 'g, 'r, 's>(
let (remaining, _) = tag("]")(remaining)?;
let (remaining, _trailing_whitespace) =
let (remaining, post_blank) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
Ok((
@@ -131,7 +131,7 @@ fn inline_footnote<'b, 'g, 'r, 's>(
FootnoteReference {
source: source.into(),
contents: Some(contents.into()),
post_blank: _trailing_whitespace.map(Into::<&str>::into),
post_blank: post_blank.map(Into::<&str>::into),
label: Some(label_contents.into()),
definition: children,
},
@@ -149,7 +149,7 @@ fn footnote_reference_only<'b, 'g, 'r, 's>(
let (remaining, _) = tag_no_case("[fn:")(input)?;
let (remaining, label_contents) = label(remaining)?;
let (remaining, _) = tag("]")(remaining)?;
let (remaining, _trailing_whitespace) =
let (remaining, post_blank) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
Ok((
@@ -157,7 +157,7 @@ fn footnote_reference_only<'b, 'g, 'r, 's>(
FootnoteReference {
source: source.into(),
contents: None,
post_blank: _trailing_whitespace.map(Into::<&str>::into),
post_blank: post_blank.map(Into::<&str>::into),
label: Some(label_contents.into()),
definition: Vec::with_capacity(0),
},

View File

@@ -1,4 +1,5 @@
use nom::branch::alt;
use nom::combinator::consumed;
use nom::combinator::eof;
use nom::combinator::recognize;
use nom::combinator::verify;
@@ -45,14 +46,14 @@ where
let standard_set_object_matcher = parser_with_context!(standard_set_object)(&parser_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
let (remaining, (children, _exit_contents)) = verify(
let (remaining, (contents, (children, _exit_contents))) = consumed(verify(
many_till(standard_set_object_matcher, exit_matcher),
|(children, _exit_contents)| !children.is_empty(),
)(remaining)?;
))(remaining)?;
// Not checking parent exit matcher because if there are any children matched then we have a valid paragraph.
let (remaining, _trailing_ws) =
let (remaining, post_blank) =
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining);
@@ -60,6 +61,8 @@ where
remaining,
Paragraph {
source: source.into(),
contents: Some(contents.into()),
post_blank: post_blank.map(Into::<&str>::into),
affiliated_keywords: parse_affiliated_keywords(
context.get_global_settings(),
affiliated_keywords,