Add use_brackets.
This commit is contained in:
@@ -2,6 +2,7 @@ use nom::branch::alt;
|
||||
use nom::bytes::complete::tag;
|
||||
use nom::character::complete::satisfy;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::peek;
|
||||
use nom::combinator::recognize;
|
||||
use nom::sequence::tuple;
|
||||
@@ -22,7 +23,7 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Entity<'s>> {
|
||||
let (remaining, _) = tag("\\")(input)?;
|
||||
let (remaining, (entity_definition, entity_name)) = name(context, remaining)?;
|
||||
let (remaining, (entity_definition, entity_name, use_brackets)) = name(context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
@@ -38,6 +39,7 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
|
||||
html: entity_definition.html,
|
||||
ascii: entity_definition.ascii,
|
||||
utf8: entity_definition.utf8,
|
||||
use_brackets,
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -46,15 +48,18 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
|
||||
fn name<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, (&'g EntityDefinition<'s>, OrgSource<'s>)> {
|
||||
) -> Res<OrgSource<'s>, (&'g EntityDefinition<'s>, OrgSource<'s>, bool)> {
|
||||
for entity in context.get_global_settings().entities {
|
||||
let result = tuple((
|
||||
tag::<_, _, CustomError<_>>(entity.name),
|
||||
alt((tag("{}"), peek(recognize(entity_end)))),
|
||||
alt((
|
||||
map(tag("{}"), |_| true),
|
||||
map(peek(recognize(entity_end)), |_| false),
|
||||
)),
|
||||
))(input);
|
||||
match result {
|
||||
Ok((remaining, (ent, _))) => {
|
||||
return Ok((remaining, (entity, ent)));
|
||||
Ok((remaining, (ent, use_brackets))) => {
|
||||
return Ok((remaining, (entity, ent, use_brackets)));
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user