Update all elements to the new AffiliatedKeywords.

This commit is contained in:
Tom Alexander
2023-10-11 14:44:25 -04:00
parent aa33fe42a8
commit 9523365090
19 changed files with 162 additions and 97 deletions

View File

@@ -17,9 +17,9 @@ use nom::multi::many_till;
use nom::sequence::preceded;
use nom::sequence::tuple;
use super::affiliated_keyword::parse_affiliated_keywords;
use super::keyword::affiliated_keyword;
use super::org_source::OrgSource;
use super::util::get_name;
use super::util::in_section;
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
use crate::context::parser_with_context;
@@ -71,19 +71,19 @@ pub(crate) fn greater_block<'b, 'g, 'r, 's>(
context,
remaining,
pre_affiliated_keywords_input,
&affiliated_keywords,
affiliated_keywords,
)?,
"quote" => quote_block(
context,
remaining,
pre_affiliated_keywords_input,
&affiliated_keywords,
affiliated_keywords,
)?,
_ => special_block(name)(
context,
remaining,
pre_affiliated_keywords_input,
&affiliated_keywords,
affiliated_keywords,
)?,
};
Ok((remaining, element))
@@ -97,7 +97,7 @@ fn center_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
pre_affiliated_keywords_input: OrgSource<'s>,
affiliated_keywords: &Vec<Keyword<'s>>,
affiliated_keywords: Vec<Keyword<'s>>,
) -> Res<OrgSource<'s>, Element<'s>> {
let (remaining, (source, children)) = greater_block_body(
context,
@@ -110,7 +110,10 @@ fn center_block<'b, 'g, 'r, 's>(
remaining,
Element::CenterBlock(CenterBlock {
source,
name: get_name(&affiliated_keywords),
affiliated_keywords: parse_affiliated_keywords(
context.get_global_settings(),
affiliated_keywords,
),
children,
}),
))
@@ -124,7 +127,7 @@ fn quote_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
pre_affiliated_keywords_input: OrgSource<'s>,
affiliated_keywords: &Vec<Keyword<'s>>,
affiliated_keywords: Vec<Keyword<'s>>,
) -> Res<OrgSource<'s>, Element<'s>> {
let (remaining, (source, children)) = greater_block_body(
context,
@@ -137,7 +140,10 @@ fn quote_block<'b, 'g, 'r, 's>(
remaining,
Element::QuoteBlock(QuoteBlock {
source,
name: get_name(&affiliated_keywords),
affiliated_keywords: parse_affiliated_keywords(
context.get_global_settings(),
affiliated_keywords,
),
children,
}),
))
@@ -149,7 +155,7 @@ fn special_block<'s>(
RefContext<'b, 'g, 'r, 's>,
OrgSource<'s>,
OrgSource<'s>,
&Vec<Keyword<'s>>,
Vec<Keyword<'s>>,
) -> Res<OrgSource<'s>, Element<'s>>
+ 's {
let context_name = format!("special block {}", name);
@@ -175,7 +181,7 @@ fn _special_block<'c, 'b, 'g, 'r, 's>(
pre_affiliated_keywords_input: OrgSource<'s>,
name: &'s str,
context_name: &'c str,
affiliated_keywords: &Vec<Keyword<'s>>,
affiliated_keywords: Vec<Keyword<'s>>,
) -> Res<OrgSource<'s>, Element<'s>> {
let (remaining, parameters) = opt(tuple((space1, parameters)))(input)?;
let (remaining, (source, children)) = greater_block_body(
@@ -189,7 +195,10 @@ fn _special_block<'c, 'b, 'g, 'r, 's>(
remaining,
Element::SpecialBlock(SpecialBlock {
source,
name: get_name(&affiliated_keywords),
affiliated_keywords: parse_affiliated_keywords(
context.get_global_settings(),
affiliated_keywords,
),
children,
block_type: name,
parameters: parameters.map(|(_, parameters)| Into::<&str>::into(parameters)),