Port the rest of the element parsers over.
This commit is contained in:
parent
767f44f94d
commit
f475754a71
@ -28,17 +28,21 @@ 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>(
|
pub(crate) fn babel_call<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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,16 +14,21 @@ 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>(
|
pub(crate) fn diary_sexp<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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)?;
|
||||||
|
@ -32,6 +32,7 @@ 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;
|
||||||
|
|
||||||
@ -39,16 +40,20 @@ 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>(
|
pub(crate) fn drawer<'b, 'g, 'r, 's, AK>(
|
||||||
|
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((
|
||||||
|
@ -101,44 +101,124 @@ fn _element<'b, 'g, 'r, 's>(
|
|||||||
|
|
||||||
element!(comment, context, input, Element::Comment);
|
element!(comment, context, input, Element::Comment);
|
||||||
|
|
||||||
let drawer_matcher = parser_with_context!(drawer)(context);
|
ak_element!(
|
||||||
let table_matcher = parser_with_context!(org_mode_table)(context);
|
drawer,
|
||||||
let verse_block_matcher = parser_with_context!(verse_block)(context);
|
&mut affiliated_keywords,
|
||||||
let comment_block_matcher = parser_with_context!(comment_block)(context);
|
post_affiliated_keywords_input,
|
||||||
let example_block_matcher = parser_with_context!(example_block)(context);
|
context,
|
||||||
let export_block_matcher = parser_with_context!(export_block)(context);
|
input,
|
||||||
let src_block_matcher = parser_with_context!(src_block)(context);
|
Element::Drawer
|
||||||
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 latex_environment_matcher = parser_with_context!(latex_environment)(context);
|
|
||||||
|
|
||||||
let (remaining, maybe_element) = {
|
ak_element!(
|
||||||
#[cfg(feature = "tracing")]
|
org_mode_table,
|
||||||
let span = span!(tracing::Level::DEBUG, "Main element block");
|
&mut affiliated_keywords,
|
||||||
#[cfg(feature = "tracing")]
|
post_affiliated_keywords_input,
|
||||||
let _enter = span.enter();
|
context,
|
||||||
|
input,
|
||||||
|
Element::Table
|
||||||
|
);
|
||||||
|
|
||||||
opt(alt((
|
ak_element!(
|
||||||
map(drawer_matcher, Element::Drawer),
|
verse_block,
|
||||||
map(table_matcher, Element::Table),
|
&mut affiliated_keywords,
|
||||||
map(verse_block_matcher, Element::VerseBlock),
|
post_affiliated_keywords_input,
|
||||||
map(comment_block_matcher, Element::CommentBlock),
|
context,
|
||||||
map(example_block_matcher, Element::ExampleBlock),
|
input,
|
||||||
map(export_block_matcher, Element::ExportBlock),
|
Element::VerseBlock
|
||||||
map(src_block_matcher, Element::SrcBlock),
|
);
|
||||||
map(clock_matcher, Element::Clock),
|
|
||||||
map(diary_sexp_matcher, Element::DiarySexp),
|
ak_element!(
|
||||||
map(fixed_width_area_matcher, Element::FixedWidthArea),
|
comment_block,
|
||||||
map(horizontal_rule_matcher, Element::HorizontalRule),
|
&mut affiliated_keywords,
|
||||||
map(latex_environment_matcher, Element::LatexEnvironment),
|
post_affiliated_keywords_input,
|
||||||
map(babel_keyword_matcher, Element::BabelCall),
|
context,
|
||||||
map(keyword_matcher, Element::Keyword),
|
input,
|
||||||
)))(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
|
||||||
|
);
|
||||||
|
|
||||||
|
ak_element!(
|
||||||
|
keyword,
|
||||||
|
&mut affiliated_keywords,
|
||||||
|
post_affiliated_keywords_input,
|
||||||
|
context,
|
||||||
|
input,
|
||||||
|
Element::Keyword
|
||||||
|
);
|
||||||
|
|
||||||
if can_be_paragraph {
|
if can_be_paragraph {
|
||||||
// Paragraph with affiliated keyword
|
// Paragraph with affiliated keyword
|
||||||
@ -162,14 +242,9 @@ fn _element<'b, 'g, 'r, 's>(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if maybe_element.is_none() {
|
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
|
||||||
"No element.",
|
"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,16 +21,21 @@ 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>(
|
pub(crate) fn fixed_width_area<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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)?;
|
||||||
|
@ -18,16 +18,21 @@ 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>(
|
pub(crate) fn horizontal_rule<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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,
|
||||||
|
@ -94,11 +94,15 @@ 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>(
|
pub(crate) fn keyword<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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)?;
|
||||||
|
@ -26,17 +26,22 @@ 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>(
|
pub(crate) fn latex_environment<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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)?;
|
||||||
|
@ -41,6 +41,7 @@ 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;
|
||||||
@ -53,11 +54,15 @@ 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>(
|
pub(crate) fn verse_block<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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)?;
|
||||||
@ -117,11 +122,15 @@ pub(crate) fn verse_block<'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 comment_block<'b, 'g, 'r, 's>(
|
pub(crate) fn comment_block<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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)?;
|
||||||
@ -161,11 +170,15 @@ pub(crate) fn comment_block<'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 example_block<'b, 'g, 'r, 's>(
|
pub(crate) fn example_block<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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),
|
||||||
@ -238,11 +251,15 @@ pub(crate) fn example_block<'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 export_block<'b, 'g, 'r, 's>(
|
pub(crate) fn export_block<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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(
|
||||||
@ -290,11 +307,15 @@ pub(crate) fn export_block<'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 src_block<'b, 'g, 'r, 's>(
|
pub(crate) fn src_block<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
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) =
|
||||||
|
@ -29,6 +29,7 @@ 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;
|
||||||
@ -40,11 +41,15 @@ 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>(
|
pub(crate) fn org_mode_table<'b, 'g, 'r, 's, AK>(
|
||||||
|
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>>
|
||||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
where
|
||||||
|
AK: IntoIterator<Item = Keyword<'s>>,
|
||||||
|
{
|
||||||
start_of_line(remaining)?;
|
start_of_line(remaining)?;
|
||||||
peek(tuple((space0, tag("|"))))(remaining)?;
|
peek(tuple((space0, tag("|"))))(remaining)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user