Compare commits
No commits in common. "1d9f91cdd25660d85da22311cf5881676ce2ca74" and "3208a04f7a512552cab99cba8750ab2c1bc57d78" have entirely different histories.
1d9f91cdd2
...
3208a04f7a
@ -1,3 +0,0 @@
|
|||||||
1. foo
|
|
||||||
#+NAME: bar
|
|
||||||
2. baz
|
|
@ -1,5 +0,0 @@
|
|||||||
* Overwrite
|
|
||||||
#+NAME: foo
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :var foo="lorem"
|
|
||||||
:END:
|
|
@ -1,3 +0,0 @@
|
|||||||
|foo|
|
|
||||||
#+NAME: bar
|
|
||||||
|baz |
|
|
@ -1,3 +0,0 @@
|
|||||||
#+NAME: foo
|
|
||||||
* bar
|
|
||||||
#+NAME: baz
|
|
@ -25,15 +25,12 @@ use crate::types::AffiliatedKeywordValue;
|
|||||||
use crate::types::AffiliatedKeywords;
|
use crate::types::AffiliatedKeywords;
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
|
|
||||||
pub(crate) fn parse_affiliated_keywords<'g, 's, AK>(
|
pub(crate) fn parse_affiliated_keywords<'g, 's>(
|
||||||
global_settings: &'g GlobalSettings<'g, 's>,
|
global_settings: &'g GlobalSettings<'g, 's>,
|
||||||
input: AK,
|
input: Vec<Keyword<'s>>,
|
||||||
) -> AffiliatedKeywords<'s>
|
) -> AffiliatedKeywords<'s> {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let mut ret = BTreeMap::new();
|
let mut ret = BTreeMap::new();
|
||||||
for kw in input {
|
for kw in input.into_iter() {
|
||||||
let translated_name = translate_name(global_settings, kw.key);
|
let translated_name = translate_name(global_settings, kw.key);
|
||||||
if is_single_string_keyword(global_settings, translated_name.as_str()) {
|
if is_single_string_keyword(global_settings, translated_name.as_str()) {
|
||||||
ret.insert(
|
ret.insert(
|
||||||
|
@ -9,11 +9,13 @@ use nom::combinator::opt;
|
|||||||
use nom::combinator::peek;
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
use nom::InputTake;
|
use nom::InputTake;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::BracketDepth;
|
use super::org_source::BracketDepth;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
use super::util::start_of_line;
|
use super::util::start_of_line;
|
||||||
@ -26,21 +28,17 @@ use crate::error::Res;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::org_line_ending;
|
use crate::parser::util::org_line_ending;
|
||||||
use crate::types::BabelCall;
|
use crate::types::BabelCall;
|
||||||
use crate::types::Keyword;
|
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn babel_call<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn babel_call<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, BabelCall<'s>>
|
) -> Res<OrgSource<'s>, BabelCall<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
let (remaining, _) = tuple((space0, tag("#+"), tag_no_case("call"), tag(":")))(remaining)?;
|
let (remaining, _) = tuple((space0, tag("#+"), tag_no_case("call"), tag(":")))(remaining)?;
|
||||||
|
|
||||||
|
@ -14,21 +14,16 @@ use crate::error::Res;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::DiarySexp;
|
use crate::types::DiarySexp;
|
||||||
use crate::types::Keyword;
|
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn diary_sexp<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn diary_sexp<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, DiarySexp<'s>>
|
) -> Res<OrgSource<'s>, DiarySexp<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
let (remaining, value) = recognize(tuple((tag("%%("), is_not("\r\n"))))(remaining)?;
|
let (remaining, value) = recognize(tuple((tag("%%("), is_not("\r\n"))))(remaining)?;
|
||||||
let (remaining, _eol) = org_line_ending(remaining)?;
|
let (remaining, _eol) = org_line_ending(remaining)?;
|
||||||
|
@ -7,10 +7,12 @@ use nom::character::complete::space0;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::not;
|
use nom::combinator::not;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
@ -30,7 +32,6 @@ use crate::parser::util::start_of_line;
|
|||||||
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
|
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
|
||||||
use crate::types::Drawer;
|
use crate::types::Drawer;
|
||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
use crate::types::Keyword;
|
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
use crate::types::SetSource;
|
use crate::types::SetSource;
|
||||||
|
|
||||||
@ -38,20 +39,16 @@ use crate::types::SetSource;
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn drawer<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn drawer<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Drawer<'s>>
|
) -> Res<OrgSource<'s>, Drawer<'s>> {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
if immediate_in_section(context, "drawer") {
|
if immediate_in_section(context, "drawer") {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Cannot nest objects of the same element".into(),
|
"Cannot nest objects of the same element".into(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
let (remaining, _leading_whitespace) = space0(remaining)?;
|
let (remaining, _leading_whitespace) = space0(remaining)?;
|
||||||
let (remaining, (_open_colon, drawer_name, _close_colon, _new_line)) = tuple((
|
let (remaining, (_open_colon, drawer_name, _close_colon, _new_line)) = tuple((
|
||||||
|
@ -18,6 +18,7 @@ use nom::sequence::preceded;
|
|||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
@ -36,7 +37,6 @@ use crate::parser::util::immediate_in_section;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::DynamicBlock;
|
use crate::types::DynamicBlock;
|
||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
use crate::types::Keyword;
|
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
use crate::types::SetSource;
|
use crate::types::SetSource;
|
||||||
|
|
||||||
@ -44,20 +44,16 @@ use crate::types::SetSource;
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn dynamic_block<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn dynamic_block<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, DynamicBlock<'s>>
|
) -> Res<OrgSource<'s>, DynamicBlock<'s>> {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
if immediate_in_section(context, "dynamic block") {
|
if immediate_in_section(context, "dynamic block") {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Cannot nest objects of the same element".into(),
|
"Cannot nest objects of the same element".into(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
|
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
let (remaining, _leading_whitespace) = space0(remaining)?;
|
let (remaining, _leading_whitespace) = space0(remaining)?;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::multi::many0;
|
use nom::combinator::map;
|
||||||
|
use nom::combinator::opt;
|
||||||
|
use nom::combinator::peek;
|
||||||
|
use nom::sequence::tuple;
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use tracing::span;
|
use tracing::span;
|
||||||
|
|
||||||
@ -18,6 +21,7 @@ use super::footnote_definition::footnote_definition;
|
|||||||
use super::greater_block::greater_block;
|
use super::greater_block::greater_block;
|
||||||
use super::horizontal_rule::horizontal_rule;
|
use super::horizontal_rule::horizontal_rule;
|
||||||
use super::keyword::affiliated_keyword;
|
use super::keyword::affiliated_keyword;
|
||||||
|
use super::keyword::affiliated_keyword_as_regular_keyword;
|
||||||
use super::keyword::keyword;
|
use super::keyword::keyword;
|
||||||
use super::latex_environment::latex_environment;
|
use super::latex_environment::latex_environment;
|
||||||
use super::lesser_block::comment_block;
|
use super::lesser_block::comment_block;
|
||||||
@ -35,8 +39,6 @@ use crate::context::RefContext;
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::error::MyError;
|
use crate::error::MyError;
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::macros::ak_element;
|
|
||||||
use crate::parser::macros::element;
|
|
||||||
use crate::parser::table::org_mode_table;
|
use crate::parser::table::org_mode_table;
|
||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
|
|
||||||
@ -58,204 +60,117 @@ fn _element<'b, 'g, 'r, 's>(
|
|||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
can_be_paragraph: bool,
|
can_be_paragraph: bool,
|
||||||
) -> Res<OrgSource<'s>, Element<'s>> {
|
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||||
let (post_affiliated_keywords_input, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
let plain_list_matcher = parser_with_context!(plain_list)(context);
|
||||||
|
let greater_block_matcher = parser_with_context!(greater_block)(context);
|
||||||
|
let dynamic_block_matcher = parser_with_context!(dynamic_block)(context);
|
||||||
|
let footnote_definition_matcher = parser_with_context!(footnote_definition)(context);
|
||||||
|
let comment_matcher = parser_with_context!(comment)(context);
|
||||||
|
let drawer_matcher = parser_with_context!(drawer)(context);
|
||||||
|
let table_matcher = parser_with_context!(org_mode_table)(context);
|
||||||
|
let verse_block_matcher = parser_with_context!(verse_block)(context);
|
||||||
|
let comment_block_matcher = parser_with_context!(comment_block)(context);
|
||||||
|
let example_block_matcher = parser_with_context!(example_block)(context);
|
||||||
|
let export_block_matcher = parser_with_context!(export_block)(context);
|
||||||
|
let src_block_matcher = parser_with_context!(src_block)(context);
|
||||||
|
let clock_matcher = parser_with_context!(clock)(context);
|
||||||
|
let diary_sexp_matcher = parser_with_context!(diary_sexp)(context);
|
||||||
|
let fixed_width_area_matcher = parser_with_context!(fixed_width_area)(context);
|
||||||
|
let horizontal_rule_matcher = parser_with_context!(horizontal_rule)(context);
|
||||||
|
let keyword_matcher = parser_with_context!(keyword)(context);
|
||||||
|
let babel_keyword_matcher = parser_with_context!(babel_call)(context);
|
||||||
|
let paragraph_matcher = parser_with_context!(paragraph)(context);
|
||||||
|
let latex_environment_matcher = parser_with_context!(latex_environment)(context);
|
||||||
|
|
||||||
let mut affiliated_keywords = affiliated_keywords.into_iter();
|
let (mut remaining, mut maybe_element) = {
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
let span = span!(tracing::Level::DEBUG, "Main element block");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
let _enter = span.enter();
|
||||||
|
|
||||||
ak_element!(
|
opt(alt((
|
||||||
plain_list,
|
map(plain_list_matcher, Element::PlainList),
|
||||||
&mut affiliated_keywords,
|
greater_block_matcher,
|
||||||
post_affiliated_keywords_input,
|
map(dynamic_block_matcher, Element::DynamicBlock),
|
||||||
context,
|
map(footnote_definition_matcher, Element::FootnoteDefinition),
|
||||||
input,
|
map(comment_matcher, Element::Comment),
|
||||||
Element::PlainList
|
map(drawer_matcher, Element::Drawer),
|
||||||
);
|
map(table_matcher, Element::Table),
|
||||||
|
map(verse_block_matcher, Element::VerseBlock),
|
||||||
|
map(comment_block_matcher, Element::CommentBlock),
|
||||||
|
map(example_block_matcher, Element::ExampleBlock),
|
||||||
|
map(export_block_matcher, Element::ExportBlock),
|
||||||
|
map(src_block_matcher, Element::SrcBlock),
|
||||||
|
map(clock_matcher, Element::Clock),
|
||||||
|
map(diary_sexp_matcher, Element::DiarySexp),
|
||||||
|
map(fixed_width_area_matcher, Element::FixedWidthArea),
|
||||||
|
map(horizontal_rule_matcher, Element::HorizontalRule),
|
||||||
|
map(latex_environment_matcher, Element::LatexEnvironment),
|
||||||
|
map(babel_keyword_matcher, Element::BabelCall),
|
||||||
|
map(keyword_matcher, Element::Keyword),
|
||||||
|
)))(input)?
|
||||||
|
};
|
||||||
|
|
||||||
ak_element!(
|
if maybe_element.is_none() && can_be_paragraph {
|
||||||
greater_block,
|
#[cfg(feature = "tracing")]
|
||||||
&mut affiliated_keywords,
|
let span = span!(tracing::Level::DEBUG, "Paragraph with affiliated keyword.");
|
||||||
post_affiliated_keywords_input,
|
#[cfg(feature = "tracing")]
|
||||||
context,
|
let _enter = span.enter();
|
||||||
input
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
let (remain, paragraph_with_affiliated_keyword) = opt(map(
|
||||||
dynamic_block,
|
tuple((
|
||||||
&mut affiliated_keywords,
|
peek(affiliated_keyword),
|
||||||
post_affiliated_keywords_input,
|
map(paragraph_matcher, Element::Paragraph),
|
||||||
context,
|
)),
|
||||||
input,
|
|(_, paragraph)| paragraph,
|
||||||
Element::DynamicBlock
|
))(remaining)?;
|
||||||
);
|
if paragraph_with_affiliated_keyword.is_some() {
|
||||||
|
remaining = remain;
|
||||||
ak_element!(
|
maybe_element = paragraph_with_affiliated_keyword;
|
||||||
footnote_definition,
|
}
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::FootnoteDefinition
|
|
||||||
);
|
|
||||||
|
|
||||||
element!(comment, context, input, Element::Comment);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
drawer,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::Drawer
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
org_mode_table,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::Table
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
verse_block,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::VerseBlock
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
comment_block,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::CommentBlock
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
example_block,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::ExampleBlock
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
export_block,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::ExportBlock
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
src_block,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::SrcBlock
|
|
||||||
);
|
|
||||||
|
|
||||||
element!(clock, context, input, Element::Clock);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
diary_sexp,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::DiarySexp
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
fixed_width_area,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::FixedWidthArea
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
horizontal_rule,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::HorizontalRule
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
latex_environment,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::LatexEnvironment
|
|
||||||
);
|
|
||||||
|
|
||||||
ak_element!(
|
|
||||||
babel_call,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::BabelCall
|
|
||||||
);
|
|
||||||
|
|
||||||
// Keyword with affiliated keywords
|
|
||||||
ak_element!(
|
|
||||||
keyword,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::Keyword
|
|
||||||
);
|
|
||||||
|
|
||||||
if can_be_paragraph {
|
|
||||||
// Paragraph with affiliated keyword
|
|
||||||
ak_element!(
|
|
||||||
paragraph,
|
|
||||||
&mut affiliated_keywords,
|
|
||||||
post_affiliated_keywords_input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::Paragraph
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keyword without affiliated keywords
|
if maybe_element.is_none() {
|
||||||
ak_element!(
|
#[cfg(feature = "tracing")]
|
||||||
keyword,
|
let span = span!(
|
||||||
std::iter::empty(),
|
tracing::Level::DEBUG,
|
||||||
input,
|
"Affiliated keyword as regular keyword."
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::Keyword
|
|
||||||
);
|
|
||||||
|
|
||||||
if can_be_paragraph {
|
|
||||||
// Paragraph without affiliated keyword
|
|
||||||
ak_element!(
|
|
||||||
paragraph,
|
|
||||||
std::iter::empty(),
|
|
||||||
input,
|
|
||||||
context,
|
|
||||||
input,
|
|
||||||
Element::Paragraph
|
|
||||||
);
|
);
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
let _enter = span.enter();
|
||||||
|
|
||||||
|
let (remain, kw) = opt(map(
|
||||||
|
parser_with_context!(affiliated_keyword_as_regular_keyword)(context),
|
||||||
|
Element::Keyword,
|
||||||
|
))(remaining)?;
|
||||||
|
if kw.is_some() {
|
||||||
|
maybe_element = kw;
|
||||||
|
remaining = remain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(nom::Err::Error(CustomError::MyError(MyError(
|
if maybe_element.is_none() && can_be_paragraph {
|
||||||
"No element.",
|
#[cfg(feature = "tracing")]
|
||||||
))))
|
let span = span!(
|
||||||
|
tracing::Level::DEBUG,
|
||||||
|
"Paragraph without affiliated keyword."
|
||||||
|
);
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
let _enter = span.enter();
|
||||||
|
|
||||||
|
let (remain, paragraph_without_affiliated_keyword) =
|
||||||
|
map(paragraph_matcher, Element::Paragraph)(remaining)?;
|
||||||
|
remaining = remain;
|
||||||
|
maybe_element = Some(paragraph_without_affiliated_keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
if maybe_element.is_none() {
|
||||||
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
|
"No element.",
|
||||||
|
))));
|
||||||
|
}
|
||||||
|
let element = maybe_element.expect("The above if-statement ensures this is Some().");
|
||||||
|
|
||||||
|
Ok((remaining, element))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) const fn detect_element(
|
pub(crate) const fn detect_element(
|
||||||
|
@ -21,21 +21,16 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::FixedWidthArea;
|
use crate::types::FixedWidthArea;
|
||||||
use crate::types::Keyword;
|
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn fixed_width_area<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn fixed_width_area<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, FixedWidthArea<'s>>
|
) -> Res<OrgSource<'s>, FixedWidthArea<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let fixed_width_area_line_matcher = parser_with_context!(fixed_width_area_line)(context);
|
let fixed_width_area_line_matcher = parser_with_context!(fixed_width_area_line)(context);
|
||||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(context);
|
let exit_matcher = parser_with_context!(exit_matcher_parser)(context);
|
||||||
let (remaining, first_line) = fixed_width_area_line_matcher(remaining)?;
|
let (remaining, first_line) = fixed_width_area_line_matcher(remaining)?;
|
||||||
|
@ -33,26 +33,21 @@ use crate::parser::util::immediate_in_section;
|
|||||||
use crate::parser::util::maybe_consume_trailing_whitespace;
|
use crate::parser::util::maybe_consume_trailing_whitespace;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::FootnoteDefinition;
|
use crate::types::FootnoteDefinition;
|
||||||
use crate::types::Keyword;
|
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn footnote_definition<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, FootnoteDefinition<'s>>
|
) -> Res<OrgSource<'s>, FootnoteDefinition<'s>> {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
if immediate_in_section(context, "footnote definition") {
|
if immediate_in_section(context, "footnote definition") {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Cannot nest objects of the same element".into(),
|
"Cannot nest objects of the same element".into(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
// Cannot be indented.
|
// Cannot be indented.
|
||||||
let (remaining, (_, lbl, _, _, _)) = tuple((
|
let (remaining, (_, lbl, _, _, _)) = tuple((
|
||||||
|
@ -18,6 +18,7 @@ use nom::sequence::preceded;
|
|||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::in_section;
|
use super::util::in_section;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
@ -47,15 +48,12 @@ use crate::types::SpecialBlock;
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn greater_block<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn greater_block<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
input: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
pre_affiliated_keywords_input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Element<'s>>
|
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||||
where
|
let pre_affiliated_keywords_input = input;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
let (input, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
{
|
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, (_begin, name)) = tuple((
|
let (remaining, (_begin, name)) = tuple((
|
||||||
@ -95,15 +93,12 @@ where
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
fn center_block<'b, 'g, 'r, 's, AK>(
|
fn center_block<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
pre_affiliated_keywords_input: OrgSource<'s>,
|
pre_affiliated_keywords_input: OrgSource<'s>,
|
||||||
affiliated_keywords: AK,
|
affiliated_keywords: Vec<Keyword<'s>>,
|
||||||
) -> Res<OrgSource<'s>, Element<'s>>
|
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, (source, children)) = greater_block_body(
|
let (remaining, (source, children)) = greater_block_body(
|
||||||
context,
|
context,
|
||||||
input,
|
input,
|
||||||
@ -128,15 +123,12 @@ where
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
fn quote_block<'b, 'g, 'r, 's, AK>(
|
fn quote_block<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
pre_affiliated_keywords_input: OrgSource<'s>,
|
pre_affiliated_keywords_input: OrgSource<'s>,
|
||||||
affiliated_keywords: AK,
|
affiliated_keywords: Vec<Keyword<'s>>,
|
||||||
) -> Res<OrgSource<'s>, Element<'s>>
|
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, (source, children)) = greater_block_body(
|
let (remaining, (source, children)) = greater_block_body(
|
||||||
context,
|
context,
|
||||||
input,
|
input,
|
||||||
@ -157,18 +149,15 @@ where
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn special_block<'s, AK>(
|
fn special_block<'s>(
|
||||||
name: &'s str,
|
name: &'s str,
|
||||||
) -> impl for<'b, 'g, 'r> Fn(
|
) -> impl for<'b, 'g, 'r> Fn(
|
||||||
RefContext<'b, 'g, 'r, 's>,
|
RefContext<'b, 'g, 'r, 's>,
|
||||||
OrgSource<'s>,
|
OrgSource<'s>,
|
||||||
OrgSource<'s>,
|
OrgSource<'s>,
|
||||||
AK,
|
Vec<Keyword<'s>>,
|
||||||
) -> Res<OrgSource<'s>, Element<'s>>
|
) -> Res<OrgSource<'s>, Element<'s>>
|
||||||
+ 's
|
+ 's {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let context_name = format!("special block {}", name);
|
let context_name = format!("special block {}", name);
|
||||||
move |context, input, pre_affiliated_keywords_input, affiliated_keywords| {
|
move |context, input, pre_affiliated_keywords_input, affiliated_keywords| {
|
||||||
_special_block(
|
_special_block(
|
||||||
@ -186,17 +175,14 @@ where
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
fn _special_block<'c, 'b, 'g, 'r, 's, AK>(
|
fn _special_block<'c, 'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
pre_affiliated_keywords_input: OrgSource<'s>,
|
pre_affiliated_keywords_input: OrgSource<'s>,
|
||||||
name: &'s str,
|
name: &'s str,
|
||||||
context_name: &'c str,
|
context_name: &'c str,
|
||||||
affiliated_keywords: AK,
|
affiliated_keywords: Vec<Keyword<'s>>,
|
||||||
) -> Res<OrgSource<'s>, Element<'s>>
|
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||||
where
|
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, parameters) = opt(tuple((space1, parameters)))(input)?;
|
let (remaining, parameters) = opt(tuple((space1, parameters)))(input)?;
|
||||||
let (remaining, (source, children)) = greater_block_body(
|
let (remaining, (source, children)) = greater_block_body(
|
||||||
context,
|
context,
|
||||||
|
@ -5,10 +5,12 @@ use nom::character::complete::space0;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many1_count;
|
use nom::multi::many1_count;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::get_consumed;
|
use super::util::get_consumed;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
@ -16,21 +18,16 @@ use crate::context::RefContext;
|
|||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::HorizontalRule;
|
use crate::types::HorizontalRule;
|
||||||
use crate::types::Keyword;
|
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn horizontal_rule<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn horizontal_rule<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, HorizontalRule<'s>>
|
) -> Res<OrgSource<'s>, HorizontalRule<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
let (remaining, _rule) = recognize(tuple((
|
let (remaining, _rule) = recognize(tuple((
|
||||||
space0,
|
space0,
|
||||||
|
@ -13,6 +13,7 @@ use nom::combinator::not;
|
|||||||
use nom::combinator::peek;
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
@ -93,15 +94,11 @@ fn _filtered_keyword<'s, F: Matcher>(
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn keyword<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn keyword<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Keyword<'s>>
|
) -> Res<OrgSource<'s>, Keyword<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, mut kw) = filtered_keyword(regular_keyword_key)(remaining)?;
|
let (remaining, mut kw) = filtered_keyword(regular_keyword_key)(remaining)?;
|
||||||
let (remaining, _trailing_ws) =
|
let (remaining, _trailing_ws) =
|
||||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||||
@ -112,6 +109,22 @@ where
|
|||||||
Ok((remaining, kw))
|
Ok((remaining, kw))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "tracing",
|
||||||
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
|
)]
|
||||||
|
pub(crate) fn affiliated_keyword_as_regular_keyword<'b, 'g, 'r, 's>(
|
||||||
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
|
input: OrgSource<'s>,
|
||||||
|
) -> Res<OrgSource<'s>, Keyword<'s>> {
|
||||||
|
let (remaining, mut kw) = affiliated_keyword(input)?;
|
||||||
|
let (remaining, _trailing_ws) =
|
||||||
|
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||||
|
let source = get_consumed(input, remaining);
|
||||||
|
kw.source = Into::<&str>::into(source);
|
||||||
|
Ok((remaining, kw))
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn affiliated_keyword<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Keyword<'s>> {
|
pub(crate) fn affiliated_keyword<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Keyword<'s>> {
|
||||||
filtered_keyword(affiliated_key)(input)
|
filtered_keyword(affiliated_key)(input)
|
||||||
|
@ -8,10 +8,12 @@ use nom::character::complete::space0;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::peek;
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::get_consumed;
|
use super::util::get_consumed;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
@ -24,22 +26,17 @@ use crate::context::RefContext;
|
|||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::Keyword;
|
|
||||||
use crate::types::LatexEnvironment;
|
use crate::types::LatexEnvironment;
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn latex_environment<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn latex_environment<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, LatexEnvironment<'s>>
|
) -> Res<OrgSource<'s>, LatexEnvironment<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let value_start = remaining;
|
let value_start = remaining;
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
let (remaining, _leading_whitespace) = space0(remaining)?;
|
let (remaining, _leading_whitespace) = space0(remaining)?;
|
||||||
|
@ -13,11 +13,13 @@ use nom::combinator::opt;
|
|||||||
use nom::combinator::peek;
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
use nom::InputTake;
|
use nom::InputTake;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
@ -39,7 +41,6 @@ use crate::types::CharOffsetInLine;
|
|||||||
use crate::types::CommentBlock;
|
use crate::types::CommentBlock;
|
||||||
use crate::types::ExampleBlock;
|
use crate::types::ExampleBlock;
|
||||||
use crate::types::ExportBlock;
|
use crate::types::ExportBlock;
|
||||||
use crate::types::Keyword;
|
|
||||||
use crate::types::LineNumber;
|
use crate::types::LineNumber;
|
||||||
use crate::types::Object;
|
use crate::types::Object;
|
||||||
use crate::types::PlainText;
|
use crate::types::PlainText;
|
||||||
@ -52,15 +53,11 @@ use crate::types::VerseBlock;
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn verse_block<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn verse_block<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, VerseBlock<'s>>
|
) -> Res<OrgSource<'s>, VerseBlock<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, _) = lesser_block_begin("verse")(context, remaining)?;
|
let (remaining, _) = lesser_block_begin("verse")(context, remaining)?;
|
||||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||||
let (remaining, _nl) = recognize(tuple((space0, line_ending)))(remaining)?;
|
let (remaining, _nl) = recognize(tuple((space0, line_ending)))(remaining)?;
|
||||||
@ -120,15 +117,11 @@ where
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn comment_block<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn comment_block<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, CommentBlock<'s>>
|
) -> Res<OrgSource<'s>, CommentBlock<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, _) = lesser_block_begin("comment")(context, remaining)?;
|
let (remaining, _) = lesser_block_begin("comment")(context, remaining)?;
|
||||||
let (remaining, _parameters) = opt(tuple((space1, data)))(remaining)?;
|
let (remaining, _parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||||
let (remaining, _nl) = recognize(tuple((space0, line_ending)))(remaining)?;
|
let (remaining, _nl) = recognize(tuple((space0, line_ending)))(remaining)?;
|
||||||
@ -168,15 +161,11 @@ where
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn example_block<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn example_block<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, ExampleBlock<'s>>
|
) -> Res<OrgSource<'s>, ExampleBlock<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, _) = lesser_block_begin("example")(context, remaining)?;
|
let (remaining, _) = lesser_block_begin("example")(context, remaining)?;
|
||||||
let (remaining, parameters) = opt(alt((
|
let (remaining, parameters) = opt(alt((
|
||||||
map(tuple((space1, example_switches)), |(_, switches)| switches),
|
map(tuple((space1, example_switches)), |(_, switches)| switches),
|
||||||
@ -249,15 +238,11 @@ where
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn export_block<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn export_block<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, ExportBlock<'s>>
|
) -> Res<OrgSource<'s>, ExportBlock<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, _) = lesser_block_begin("export")(context, remaining)?;
|
let (remaining, _) = lesser_block_begin("export")(context, remaining)?;
|
||||||
// https://orgmode.org/worg/org-syntax.html#Blocks claims that export blocks must have a single word for data but testing shows no data and multi-word data still parses as an export block.
|
// https://orgmode.org/worg/org-syntax.html#Blocks claims that export blocks must have a single word for data but testing shows no data and multi-word data still parses as an export block.
|
||||||
let (remaining, export_type) = opt(map(
|
let (remaining, export_type) = opt(map(
|
||||||
@ -305,15 +290,11 @@ where
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn src_block<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn src_block<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, SrcBlock<'s>>
|
) -> Res<OrgSource<'s>, SrcBlock<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let (remaining, _) = lesser_block_begin("src")(context, remaining)?;
|
let (remaining, _) = lesser_block_begin("src")(context, remaining)?;
|
||||||
// https://orgmode.org/worg/org-syntax.html#Blocks claims that data is mandatory and must follow the LANGUAGE SWITCHES ARGUMENTS pattern but testing has shown that no data and incorrect data here will still parse to a src block.
|
// https://orgmode.org/worg/org-syntax.html#Blocks claims that data is mandatory and must follow the LANGUAGE SWITCHES ARGUMENTS pattern but testing has shown that no data and incorrect data here will still parse to a src block.
|
||||||
let (remaining, language) =
|
let (remaining, language) =
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
/// Parse an element that has affiliated keywords.
|
|
||||||
macro_rules! ak_element {
|
|
||||||
($parser:ident, $affiliated_keywords:expr, $post_affiliated_keywords_input: expr, $context: expr, $input: expr, $wrapper: expr) => {
|
|
||||||
if let Ok((remaining, ele)) = $parser(
|
|
||||||
$affiliated_keywords,
|
|
||||||
$post_affiliated_keywords_input,
|
|
||||||
$context,
|
|
||||||
$input,
|
|
||||||
) {
|
|
||||||
return Ok((remaining, $wrapper(ele)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
($parser:ident, $affiliated_keywords:expr, $post_affiliated_keywords_input: expr, $context: expr, $input: expr) => {
|
|
||||||
if let Ok((remaining, ele)) = $parser(
|
|
||||||
$affiliated_keywords,
|
|
||||||
$post_affiliated_keywords_input,
|
|
||||||
$context,
|
|
||||||
$input,
|
|
||||||
) {
|
|
||||||
return Ok((remaining, ele));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) use ak_element;
|
|
||||||
|
|
||||||
macro_rules! element {
|
|
||||||
($parser:ident, $context: expr, $input: expr, $wrapper: expr) => {
|
|
||||||
if let Ok((remaining, ele)) = $parser($context, $input) {
|
|
||||||
return Ok((remaining, $wrapper(ele)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
($parser:ident, $context: expr, $input: expr) => {
|
|
||||||
if let Ok((remaining, ele)) = $parser($context, $input) {
|
|
||||||
return Ok((remaining, ele));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) use element;
|
|
@ -27,7 +27,6 @@ mod latex_environment;
|
|||||||
mod latex_fragment;
|
mod latex_fragment;
|
||||||
mod lesser_block;
|
mod lesser_block;
|
||||||
mod line_break;
|
mod line_break;
|
||||||
mod macros;
|
|
||||||
mod object_parser;
|
mod object_parser;
|
||||||
mod org_macro;
|
mod org_macro;
|
||||||
mod org_source;
|
mod org_source;
|
||||||
|
@ -2,12 +2,14 @@ use nom::branch::alt;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
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::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
use super::element_parser::detect_element;
|
use super::element_parser::detect_element;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::blank_line;
|
use super::util::blank_line;
|
||||||
use super::util::get_consumed;
|
use super::util::get_consumed;
|
||||||
@ -21,22 +23,17 @@ use crate::error::Res;
|
|||||||
use crate::parser::object_parser::standard_set_object;
|
use crate::parser::object_parser::standard_set_object;
|
||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::Keyword;
|
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn paragraph<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn paragraph<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Paragraph<'s>>
|
) -> Res<OrgSource<'s>, Paragraph<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let contexts = [ContextElement::ExitMatcherNode(ExitMatcherNode {
|
let contexts = [ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
class: ExitClass::Gamma,
|
class: ExitClass::Gamma,
|
||||||
exit_matcher: ¶graph_end,
|
exit_matcher: ¶graph_end,
|
||||||
|
@ -43,7 +43,6 @@ use crate::parser::util::org_space;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::CheckboxType;
|
use crate::types::CheckboxType;
|
||||||
use crate::types::IndentationLevel;
|
use crate::types::IndentationLevel;
|
||||||
use crate::types::Keyword;
|
|
||||||
use crate::types::Object;
|
use crate::types::Object;
|
||||||
use crate::types::PlainList;
|
use crate::types::PlainList;
|
||||||
use crate::types::PlainListItem;
|
use crate::types::PlainListItem;
|
||||||
@ -84,15 +83,12 @@ pub(crate) fn detect_plain_list<'b, 'g, 'r, 's>(
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn plain_list<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn plain_list<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, PlainList<'s>>
|
) -> Res<OrgSource<'s>, PlainList<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
let contexts = [
|
let contexts = [
|
||||||
ContextElement::Context("plain list"),
|
ContextElement::Context("plain list"),
|
||||||
ContextElement::ConsumeTrailingWhitespace(true),
|
ContextElement::ConsumeTrailingWhitespace(true),
|
||||||
@ -584,8 +580,8 @@ mod tests {
|
|||||||
let global_settings = GlobalSettings::default();
|
let global_settings = GlobalSettings::default();
|
||||||
let initial_context = ContextElement::document_context();
|
let initial_context = ContextElement::document_context();
|
||||||
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
||||||
let (remaining, result) =
|
let plain_list_matcher = parser_with_context!(plain_list)(&initial_context);
|
||||||
plain_list(std::iter::empty(), input, &initial_context, input).unwrap();
|
let (remaining, result) = plain_list_matcher(input).unwrap();
|
||||||
assert_eq!(Into::<&str>::into(remaining), "");
|
assert_eq!(Into::<&str>::into(remaining), "");
|
||||||
assert_eq!(result.get_standard_properties().get_source(), "1.");
|
assert_eq!(result.get_standard_properties().get_source(), "1.");
|
||||||
}
|
}
|
||||||
@ -596,8 +592,8 @@ mod tests {
|
|||||||
let global_settings = GlobalSettings::default();
|
let global_settings = GlobalSettings::default();
|
||||||
let initial_context = ContextElement::document_context();
|
let initial_context = ContextElement::document_context();
|
||||||
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
||||||
let (remaining, result) =
|
let plain_list_matcher = parser_with_context!(plain_list)(&initial_context);
|
||||||
plain_list(std::iter::empty(), input, &initial_context, input).unwrap();
|
let (remaining, result) = plain_list_matcher(input).unwrap();
|
||||||
assert_eq!(Into::<&str>::into(remaining), "");
|
assert_eq!(Into::<&str>::into(remaining), "");
|
||||||
assert_eq!(result.get_standard_properties().get_source(), "1. foo");
|
assert_eq!(result.get_standard_properties().get_source(), "1. foo");
|
||||||
}
|
}
|
||||||
@ -609,7 +605,8 @@ mod tests {
|
|||||||
let global_settings = GlobalSettings::default();
|
let global_settings = GlobalSettings::default();
|
||||||
let initial_context = ContextElement::document_context();
|
let initial_context = ContextElement::document_context();
|
||||||
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
||||||
let result = plain_list(std::iter::empty(), input, &initial_context, input);
|
let plain_list_matcher = parser_with_context!(plain_list)(&initial_context);
|
||||||
|
let result = plain_list_matcher(input);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,7 +617,8 @@ mod tests {
|
|||||||
let global_settings = GlobalSettings::default();
|
let global_settings = GlobalSettings::default();
|
||||||
let initial_context = ContextElement::document_context();
|
let initial_context = ContextElement::document_context();
|
||||||
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
||||||
let result = plain_list(std::iter::empty(), input, &initial_context, input);
|
let plain_list_matcher = parser_with_context!(plain_list)(&initial_context);
|
||||||
|
let result = plain_list_matcher(input);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ use crate::context::RefContext;
|
|||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::Keyword;
|
|
||||||
use crate::types::Table;
|
use crate::types::Table;
|
||||||
use crate::types::TableCell;
|
use crate::types::TableCell;
|
||||||
use crate::types::TableRow;
|
use crate::types::TableRow;
|
||||||
@ -41,15 +40,11 @@ use crate::types::TableRow;
|
|||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
)]
|
)]
|
||||||
pub(crate) fn org_mode_table<'b, 'g, 'r, 's, AK>(
|
pub(crate) fn org_mode_table<'b, 'g, 'r, 's>(
|
||||||
affiliated_keywords: AK,
|
|
||||||
remaining: OrgSource<'s>,
|
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Table<'s>>
|
) -> Res<OrgSource<'s>, Table<'s>> {
|
||||||
where
|
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||||
AK: IntoIterator<Item = Keyword<'s>>,
|
|
||||||
{
|
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
peek(tuple((space0, tag("|"))))(remaining)?;
|
peek(tuple((space0, tag("|"))))(remaining)?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user