Support keywords with colons in the key and without a space between the colon and value.
This commit is contained in:
parent
f30069efe7
commit
7545fb7e1a
@ -5,8 +5,8 @@ use nom::bytes::complete::tag_no_case;
|
|||||||
use nom::bytes::complete::take_while1;
|
use nom::bytes::complete::take_while1;
|
||||||
use nom::character::complete::anychar;
|
use nom::character::complete::anychar;
|
||||||
use nom::character::complete::line_ending;
|
use nom::character::complete::line_ending;
|
||||||
|
use nom::character::complete::one_of;
|
||||||
use nom::character::complete::space0;
|
use nom::character::complete::space0;
|
||||||
use nom::character::complete::space1;
|
|
||||||
use nom::combinator::consumed;
|
use nom::combinator::consumed;
|
||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::not;
|
use nom::combinator::not;
|
||||||
@ -66,7 +66,7 @@ fn _filtered_keyword<'s, F: Matcher>(
|
|||||||
}
|
}
|
||||||
Err(_) => {}
|
Err(_) => {}
|
||||||
};
|
};
|
||||||
let (remaining, _ws) = space1(remaining)?;
|
let (remaining, _ws) = space0(remaining)?;
|
||||||
let (remaining, parsed_value) = recognize(many_till(
|
let (remaining, parsed_value) = recognize(many_till(
|
||||||
anychar,
|
anychar,
|
||||||
peek(tuple((space0, alt((line_ending, eof))))),
|
peek(tuple((space0, alt((line_ending, eof))))),
|
||||||
@ -113,11 +113,15 @@ fn babel_call_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>
|
|||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn regular_keyword_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
fn regular_keyword_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
recognize(tuple((
|
not(peek(alt((tag_no_case("call"), tag_no_case("begin")))))(input)?;
|
||||||
not(peek(tag_no_case("call"))),
|
recognize(many_till(
|
||||||
not(peek(tag_no_case("begin"))),
|
anychar,
|
||||||
is_not(" \t\r\n:"),
|
peek(alt((
|
||||||
)))(input)
|
recognize(one_of(" \t\r\n")), // Give up if we hit whitespace
|
||||||
|
recognize(tuple((tag(":"), one_of(" \t\r\n")))), // Stop if we see a colon followed by whitespace
|
||||||
|
recognize(tuple((tag(":"), is_not(" \t\r\n:"), not(tag(":"))))), // Stop if we see a colon that is the last colon before whitespace. This is for keywords like "#+foo:bar:baz: lorem: ipsum" which would have the key "foo:bar:baz".
|
||||||
|
))),
|
||||||
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
Loading…
Reference in New Issue
Block a user