Remove context from functions that no longer need it.
This commit is contained in:
parent
ba72cc1b29
commit
49d1cef7ae
@ -26,7 +26,6 @@ use crate::context::Context;
|
||||
use crate::context::ContextElement;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::context::RefContext;
|
||||
use crate::error::Res;
|
||||
use crate::types::AffiliatedKeywordValue;
|
||||
use crate::types::AffiliatedKeywords;
|
||||
@ -36,15 +35,14 @@ use crate::types::Keyword;
|
||||
feature = "tracing",
|
||||
tracing::instrument(ret, level = "debug", skip(context))
|
||||
)]
|
||||
pub(crate) fn affiliated_keywords<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
pub(crate) fn affiliated_keywords<'s>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Vec<Keyword<'s>>> {
|
||||
let mut ret = Vec::new();
|
||||
let mut remaining = input;
|
||||
|
||||
loop {
|
||||
let result = affiliated_keyword(context, remaining);
|
||||
let result = affiliated_keyword(remaining);
|
||||
match result {
|
||||
Ok((remain, kw)) => {
|
||||
remaining = remain;
|
||||
@ -68,8 +66,8 @@ where
|
||||
{
|
||||
let mut ret = BTreeMap::new();
|
||||
for kw in input {
|
||||
let translated_name = translate_name(global_settings, kw.key);
|
||||
let keyword_type = identify_keyword_type(global_settings, translated_name.as_str());
|
||||
let translated_name = translate_name(kw.key);
|
||||
let keyword_type = identify_keyword_type(translated_name.as_str());
|
||||
match keyword_type {
|
||||
AffiliatedKeywordType::SingleString => {
|
||||
ret.insert(
|
||||
@ -154,7 +152,7 @@ where
|
||||
AffiliatedKeywords { keywords: ret }
|
||||
}
|
||||
|
||||
fn translate_name<'g, 's>(global_settings: &'g GlobalSettings<'g, 's>, name: &'s str) -> String {
|
||||
fn translate_name<'g, 's>(name: &'s str) -> String {
|
||||
let name_until_optval = name
|
||||
.split_once('[')
|
||||
.map(|(before, _after)| before)
|
||||
@ -174,10 +172,7 @@ enum AffiliatedKeywordType {
|
||||
ObjectTree,
|
||||
}
|
||||
|
||||
fn identify_keyword_type<'g, 's>(
|
||||
global_settings: &'g GlobalSettings<'g, 's>,
|
||||
name: &'s str,
|
||||
) -> AffiliatedKeywordType {
|
||||
fn identify_keyword_type<'g, 's>(name: &'s str) -> AffiliatedKeywordType {
|
||||
let is_multiple = ["CAPTION", "HEADER"]
|
||||
.into_iter()
|
||||
.any(|candidate| name.eq_ignore_ascii_case(candidate))
|
||||
|
@ -59,8 +59,7 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||
#[cfg(feature = "event_count")]
|
||||
record_event(EventType::ElementStart, input);
|
||||
let (post_affiliated_keywords_input, affiliated_keywords) =
|
||||
affiliated_keywords(context, input)?;
|
||||
let (post_affiliated_keywords_input, affiliated_keywords) = affiliated_keywords(input)?;
|
||||
|
||||
let mut affiliated_keywords = affiliated_keywords.into_iter();
|
||||
|
||||
@ -277,8 +276,7 @@ fn _detect_element<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
can_be_paragraph: bool,
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
let (post_affiliated_keywords_input, affiliated_keywords) =
|
||||
affiliated_keywords(context, input)?;
|
||||
let (post_affiliated_keywords_input, affiliated_keywords) = affiliated_keywords(input)?;
|
||||
|
||||
let mut affiliated_keywords = affiliated_keywords.into_iter();
|
||||
|
||||
|
@ -21,7 +21,6 @@ use super::org_source::OrgSource;
|
||||
use super::util::get_consumed;
|
||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||
use super::util::org_line_ending;
|
||||
use crate::context::bind_context;
|
||||
use crate::context::constants::ORG_ELEMENT_AFFILIATED_KEYWORDS;
|
||||
use crate::context::constants::ORG_ELEMENT_DUAL_KEYWORDS;
|
||||
use crate::context::RefContext;
|
||||
@ -100,11 +99,8 @@ where
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub(crate) fn affiliated_keyword<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Keyword<'s>> {
|
||||
filtered_keyword(bind_context!(affiliated_key, context))(input)
|
||||
pub(crate) fn affiliated_keyword<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Keyword<'s>> {
|
||||
filtered_keyword(affiliated_key)(input)
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
@ -139,21 +135,15 @@ fn regular_keyword_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn affiliated_key<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
element!(dual_affiliated_key, context, input);
|
||||
element!(plain_affiliated_key, context, input);
|
||||
fn affiliated_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
element!(dual_affiliated_key, input);
|
||||
element!(plain_affiliated_key, input);
|
||||
element!(export_keyword, input);
|
||||
Err(nom::Err::Error(CustomError::Static("No affiliated key.")))
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn plain_affiliated_key<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
fn plain_affiliated_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
for keyword in ORG_ELEMENT_AFFILIATED_KEYWORDS {
|
||||
let result = map(
|
||||
tuple((tag_no_case::<_, _, CustomError>(keyword), peek(tag(":")))),
|
||||
@ -168,10 +158,7 @@ fn plain_affiliated_key<'b, 'g, 'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn dual_affiliated_key<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
fn dual_affiliated_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
for keyword in ORG_ELEMENT_DUAL_KEYWORDS {
|
||||
let result = recognize(tuple((
|
||||
tag_no_case::<_, _, CustomError>(keyword),
|
||||
|
Loading…
Reference in New Issue
Block a user