Fix simple citations by making prefixes and suffixes optional.
This commit is contained in:
@@ -29,13 +29,14 @@ use crate::parser::Object;
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn citation<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Citation<'s>> {
|
||||
// TODO: Despite being a standard object, citations cannot exist inside the global prefix/suffix for other citations because citations must contain something that matches @key which is forbidden inside the global prefix/suffix. This TODO is to evaluate if its worth putting in an explicit check for this (which can be easily accomplished by checking the output of `get_bracket_depth()`). I suspect its not worth it because I expect, outside of intentionally crafted inputs, this parser will exit immediately inside a citation since it is unlikely to find the "[cite" substring inside a citation global prefix/suffix.
|
||||
let (remaining, _) = tag_no_case("[cite")(input)?;
|
||||
let (remaining, _) = opt(citestyle)(remaining)?;
|
||||
let (remaining, _) = tag(":")(remaining)?;
|
||||
let (remaining, _prefix) = parser_with_context!(global_prefix)(context)(remaining)?;
|
||||
let (remaining, _prefix) = opt(parser_with_context!(global_prefix)(context))(remaining)?;
|
||||
let (remaining, _references) =
|
||||
many0(parser_with_context!(citation_reference)(context))(remaining)?;
|
||||
let (remaining, _suffix) = parser_with_context!(global_suffix)(context)(remaining)?;
|
||||
let (remaining, _suffix) = opt(parser_with_context!(global_suffix)(context))(remaining)?;
|
||||
let (remaining, _) = tag("]")(remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((remaining, Citation { source }))
|
||||
|
||||
Reference in New Issue
Block a user