Fix parsing semicolons.

This commit is contained in:
Tom Alexander 2023-07-21 18:42:22 -04:00
parent 640a9375bc
commit d678391789
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 8 additions and 4 deletions

View File

@ -5,9 +5,9 @@ use nom::character::complete::anychar;
use nom::combinator::opt; use nom::combinator::opt;
use nom::combinator::recognize; use nom::combinator::recognize;
use nom::combinator::verify; use nom::combinator::verify;
use nom::multi::many0;
use nom::multi::many1; use nom::multi::many1;
use nom::multi::many_till; use nom::multi::many_till;
use nom::multi::separated_list1;
use nom::sequence::tuple; use nom::sequence::tuple;
use super::Context; use super::Context;
@ -35,8 +35,11 @@ pub fn citation<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str
let (remaining, _) = tag(":")(remaining)?; let (remaining, _) = tag(":")(remaining)?;
let (remaining, _prefix) = opt(parser_with_context!(global_prefix)(context))(remaining)?; let (remaining, _prefix) = opt(parser_with_context!(global_prefix)(context))(remaining)?;
let (remaining, _references) = let (remaining, _references) =
many0(parser_with_context!(citation_reference)(context))(remaining)?; separated_list1(tag(";"), parser_with_context!(citation_reference)(context))(remaining)?;
let (remaining, _suffix) = opt(parser_with_context!(global_suffix)(context))(remaining)?; let (remaining, _suffix) = opt(tuple((
tag(";"),
parser_with_context!(global_suffix)(context),
)))(remaining)?;
let (remaining, _) = tag("]")(remaining)?; let (remaining, _) = tag("]")(remaining)?;
let source = get_consumed(input, remaining); let source = get_consumed(input, remaining);
Ok((remaining, Citation { source })) Ok((remaining, Citation { source }))
@ -86,6 +89,7 @@ fn global_prefix<'r, 's>(
), ),
|(children, _exit_contents)| !children.is_empty(), |(children, _exit_contents)| !children.is_empty(),
)(input)?; )(input)?;
let (remaining, _) = tag(";")(remaining)?;
Ok((remaining, children)) Ok((remaining, children))
} }

View File

@ -1 +1 @@
[cite:@foo] [cite/a/b-_/foo:globalprefix;keyprefix @foo keysuffix;globalsuffix]