2023-04-22 02:33:10 +00:00
|
|
|
use nom::branch::alt;
|
2023-04-22 02:36:21 +00:00
|
|
|
use nom::bytes::complete::is_not;
|
2023-04-22 02:33:10 +00:00
|
|
|
use nom::bytes::complete::tag;
|
|
|
|
use nom::character::complete::line_ending;
|
|
|
|
use nom::character::complete::space0;
|
2023-04-22 02:36:21 +00:00
|
|
|
use nom::character::complete::space1;
|
2023-04-22 02:33:10 +00:00
|
|
|
use nom::combinator::eof;
|
|
|
|
use nom::combinator::recognize;
|
|
|
|
use nom::sequence::tuple;
|
|
|
|
|
|
|
|
use super::Context;
|
|
|
|
use crate::error::Res;
|
|
|
|
use crate::parser::util::start_of_line;
|
|
|
|
use crate::parser::Keyword;
|
|
|
|
|
|
|
|
#[tracing::instrument(ret, level = "debug")]
|
|
|
|
pub fn keyword<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Keyword<'s>> {
|
|
|
|
start_of_line(context, input)?;
|
2023-04-22 02:36:21 +00:00
|
|
|
// TODO: When key is a member of org-element-parsed-keywords, value can contain the standard set objects, excluding footnote references.
|
2023-04-22 02:33:10 +00:00
|
|
|
let (remaining, rule) = recognize(tuple((
|
|
|
|
space0,
|
2023-04-22 02:36:21 +00:00
|
|
|
tag("#+"),
|
|
|
|
is_not(" \t\r\n:"),
|
|
|
|
tag(":"),
|
|
|
|
space1,
|
|
|
|
is_not("\r\n"),
|
2023-04-22 02:33:10 +00:00
|
|
|
alt((line_ending, eof)),
|
|
|
|
)))(input)?;
|
|
|
|
Ok((remaining, Keyword { source: rule }))
|
|
|
|
}
|