Port the rest of the element parsers over.
This commit is contained in:
@@ -41,6 +41,7 @@ use crate::types::CharOffsetInLine;
|
||||
use crate::types::CommentBlock;
|
||||
use crate::types::ExampleBlock;
|
||||
use crate::types::ExportBlock;
|
||||
use crate::types::Keyword;
|
||||
use crate::types::LineNumber;
|
||||
use crate::types::Object;
|
||||
use crate::types::PlainText;
|
||||
@@ -53,11 +54,15 @@ use crate::types::VerseBlock;
|
||||
feature = "tracing",
|
||||
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>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, VerseBlock<'s>> {
|
||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
) -> Res<OrgSource<'s>, VerseBlock<'s>>
|
||||
where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
let (remaining, _) = lesser_block_begin("verse")(context, remaining)?;
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(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",
|
||||
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>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, CommentBlock<'s>> {
|
||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
) -> Res<OrgSource<'s>, CommentBlock<'s>>
|
||||
where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
let (remaining, _) = lesser_block_begin("comment")(context, remaining)?;
|
||||
let (remaining, _parameters) = opt(tuple((space1, data)))(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",
|
||||
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>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ExampleBlock<'s>> {
|
||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
) -> Res<OrgSource<'s>, ExampleBlock<'s>>
|
||||
where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
let (remaining, _) = lesser_block_begin("example")(context, remaining)?;
|
||||
let (remaining, parameters) = opt(alt((
|
||||
map(tuple((space1, example_switches)), |(_, switches)| switches),
|
||||
@@ -238,11 +251,15 @@ pub(crate) fn example_block<'b, 'g, 'r, 's>(
|
||||
feature = "tracing",
|
||||
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>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ExportBlock<'s>> {
|
||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
) -> Res<OrgSource<'s>, ExportBlock<'s>>
|
||||
where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
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.
|
||||
let (remaining, export_type) = opt(map(
|
||||
@@ -290,11 +307,15 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
|
||||
feature = "tracing",
|
||||
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>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, SrcBlock<'s>> {
|
||||
let (remaining, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
) -> Res<OrgSource<'s>, SrcBlock<'s>>
|
||||
where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
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.
|
||||
let (remaining, language) =
|
||||
|
||||
Reference in New Issue
Block a user