Merge branch 'citation_properties'
Some checks failed
rustfmt Build rustfmt has succeeded
rust-foreign-document-test Build rust-foreign-document-test has failed
rust-build Build rust-build has succeeded
rust-test Build rust-test has failed

This commit is contained in:
Tom Alexander 2023-10-09 19:14:05 -04:00
commit 53b9deff10
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
54 changed files with 1439 additions and 488 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target /target
Cargo.lock Cargo.lock
TODO.org

View File

@ -0,0 +1,2 @@
# This test causes problems with regular links if we do not create a new ContextTree when calling into confine_context.
- foo [[info:bar][baz]] lorem

View File

@ -1 +1,3 @@
**foo**
foo ** bar ** baz foo ** bar ** baz

View File

@ -0,0 +1 @@
__foo_bar_baz__

View File

@ -1,36 +1,46 @@
use std::fmt::Debug; use std::fmt::Debug;
use super::diff::artificial_diff_scope;
use super::diff::compare_ast_node;
use super::diff::DiffEntry;
use super::diff::DiffStatus; use super::diff::DiffStatus;
use super::sexp::unquote; use super::sexp::unquote;
use super::sexp::Token; use super::sexp::Token;
use super::util::get_property; use super::util::get_property;
use super::util::get_property_quoted_string; use super::util::get_property_quoted_string;
use super::util::get_property_unquoted_atom; use super::util::get_property_unquoted_atom;
use crate::types::AstNode;
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum EmacsField<'s> { pub(crate) enum EmacsField<'s> {
Required(&'s str), Required(&'s str),
#[allow(dead_code)]
Optional(&'s str), Optional(&'s str),
} }
#[derive(Debug)]
pub(crate) enum ComparePropertiesResult<'b, 's> {
NoChange,
/// Return when you want the status for "this" node to change (as opposed to collecting child status).
SelfChange(DiffStatus, Option<String>),
DiffEntry(DiffEntry<'b, 's>),
}
/// Do no comparison. /// Do no comparison.
/// ///
/// This is for when you want to acknowledge that a field exists in the emacs token, but you do not have any validation for it when using the compare_properties!() macro. Ideally, this should be kept to a minimum since this represents untested values. /// This is for when you want to acknowledge that a field exists in the emacs token, but you do not have any validation for it when using the compare_properties!() macro. Ideally, this should be kept to a minimum since this represents untested values.
#[allow(dead_code)]
pub(crate) fn compare_noop<'b, 's, 'x, R, RG>( pub(crate) fn compare_noop<'b, 's, 'x, R, RG>(
_source: &'s str,
_emacs: &'b Token<'s>, _emacs: &'b Token<'s>,
_rust_node: R, _rust_node: R,
_emacs_field: &'x str, _emacs_field: &'x str,
_rust_value_getter: RG, _rust_value_getter: RG,
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> { ) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>> {
Ok(None) Ok(ComparePropertiesResult::NoChange)
} }
/// Do no comparison. /// Do no comparison.
/// ///
/// This is for when you want to acknowledge that a field exists in the emacs token, but you do not have any validation for it when using the compare_properties!() macro. Ideally, this should be kept to a minimum since this represents untested values. /// This is for when you want to acknowledge that a field exists in the emacs token, but you do not have any validation for it when using the compare_properties!() macro. Ideally, this should be kept to a minimum since this represents untested values.
#[allow(dead_code)]
pub(crate) fn compare_identity() -> () { pub(crate) fn compare_identity() -> () {
() ()
} }
@ -39,11 +49,12 @@ pub(crate) fn compare_identity() -> () {
/// ///
/// This is usually used for fields which, in my testing, are always nil. Using this compare function instead of simply doing a compare_noop will enable us to be alerted when we finally come across an org-mode document that has a value other than nil for the property. /// This is usually used for fields which, in my testing, are always nil. Using this compare function instead of simply doing a compare_noop will enable us to be alerted when we finally come across an org-mode document that has a value other than nil for the property.
pub(crate) fn compare_property_always_nil<'b, 's, 'x, R, RG>( pub(crate) fn compare_property_always_nil<'b, 's, 'x, R, RG>(
_source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
_rust_node: R, _rust_node: R,
emacs_field: &'x str, emacs_field: &'x str,
_rust_value_getter: RG, _rust_value_getter: RG,
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> { ) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>> {
let value = get_property(emacs, emacs_field)?; let value = get_property(emacs, emacs_field)?;
if value.is_some() { if value.is_some() {
let this_status = DiffStatus::Bad; let this_status = DiffStatus::Bad;
@ -51,9 +62,9 @@ pub(crate) fn compare_property_always_nil<'b, 's, 'x, R, RG>(
"{} was expected to always be nil: {:?}", "{} was expected to always be nil: {:?}",
emacs_field, value emacs_field, value
)); ));
Ok(Some((this_status, message))) Ok(ComparePropertiesResult::SelfChange(this_status, message))
} else { } else {
Ok(None) Ok(ComparePropertiesResult::NoChange)
} }
} }
@ -65,11 +76,12 @@ pub(crate) fn compare_property_quoted_string<
RV: AsRef<str> + std::fmt::Debug, RV: AsRef<str> + std::fmt::Debug,
RG: Fn(R) -> Option<RV>, RG: Fn(R) -> Option<RV>,
>( >(
_source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust_node: R, rust_node: R,
emacs_field: &'x str, emacs_field: &'x str,
rust_value_getter: RG, rust_value_getter: RG,
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> { ) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>> {
let value = get_property_quoted_string(emacs, emacs_field)?; let value = get_property_quoted_string(emacs, emacs_field)?;
let rust_value = rust_value_getter(rust_node); let rust_value = rust_value_getter(rust_node);
if rust_value.as_ref().map(|s| s.as_ref()) != value.as_ref().map(String::as_str) { if rust_value.as_ref().map(|s| s.as_ref()) != value.as_ref().map(String::as_str) {
@ -78,18 +90,19 @@ pub(crate) fn compare_property_quoted_string<
"{} mismatch (emacs != rust) {:?} != {:?}", "{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, value, rust_value emacs_field, value, rust_value
)); ));
Ok(Some((this_status, message))) Ok(ComparePropertiesResult::SelfChange(this_status, message))
} else { } else {
Ok(None) Ok(ComparePropertiesResult::NoChange)
} }
} }
pub(crate) fn compare_property_unquoted_atom<'b, 's, 'x, R, RG: Fn(R) -> Option<&'s str>>( pub(crate) fn compare_property_unquoted_atom<'b, 's, 'x, R, RG: Fn(R) -> Option<&'s str>>(
_source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust_node: R, rust_node: R,
emacs_field: &'x str, emacs_field: &'x str,
rust_value_getter: RG, rust_value_getter: RG,
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> { ) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>> {
let value = get_property_unquoted_atom(emacs, emacs_field)?; let value = get_property_unquoted_atom(emacs, emacs_field)?;
let rust_value = rust_value_getter(rust_node); let rust_value = rust_value_getter(rust_node);
if rust_value != value { if rust_value != value {
@ -98,9 +111,9 @@ pub(crate) fn compare_property_unquoted_atom<'b, 's, 'x, R, RG: Fn(R) -> Option<
"{} mismatch (emacs != rust) {:?} != {:?}", "{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, value, rust_value emacs_field, value, rust_value
)); ));
Ok(Some((this_status, message))) Ok(ComparePropertiesResult::SelfChange(this_status, message))
} else { } else {
Ok(None) Ok(ComparePropertiesResult::NoChange)
} }
} }
@ -113,11 +126,12 @@ pub(crate) fn compare_property_list_of_quoted_string<
RI: Iterator<Item = RV>, RI: Iterator<Item = RV>,
RG: Fn(R) -> Option<RI>, RG: Fn(R) -> Option<RI>,
>( >(
_source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust_node: R, rust_node: R,
emacs_field: &'x str, emacs_field: &'x str,
rust_value_getter: RG, rust_value_getter: RG,
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> { ) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>> {
let value = get_property(emacs, emacs_field)? let value = get_property(emacs, emacs_field)?
.map(Token::as_list) .map(Token::as_list)
.map_or(Ok(None), |r| r.map(Some))?; .map_or(Ok(None), |r| r.map(Some))?;
@ -132,7 +146,7 @@ pub(crate) fn compare_property_list_of_quoted_string<
"{} mismatch (emacs != rust) {:?} != {:?}", "{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, value, rust_value emacs_field, value, rust_value
)); ));
return Ok(Some((this_status, message))); return Ok(ComparePropertiesResult::SelfChange(this_status, message));
} }
(Some(el), Some(rl)) if el.len() != rl.len() => { (Some(el), Some(rl)) if el.len() != rl.len() => {
let this_status = DiffStatus::Bad; let this_status = DiffStatus::Bad;
@ -140,7 +154,7 @@ pub(crate) fn compare_property_list_of_quoted_string<
"{} mismatch (emacs != rust) {:?} != {:?}", "{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, value, rust_value emacs_field, value, rust_value
)); ));
return Ok(Some((this_status, message))); return Ok(ComparePropertiesResult::SelfChange(this_status, message));
} }
(Some(el), Some(rl)) => { (Some(el), Some(rl)) => {
for (e, r) in el.iter().zip(rl) { for (e, r) in el.iter().zip(rl) {
@ -152,20 +166,21 @@ pub(crate) fn compare_property_list_of_quoted_string<
"{} mismatch (emacs != rust) {:?} != {:?}. Full list: {:?} != {:?}", "{} mismatch (emacs != rust) {:?} != {:?}. Full list: {:?} != {:?}",
emacs_field, e, r, value, rust_value emacs_field, e, r, value, rust_value
)); ));
return Ok(Some((this_status, message))); return Ok(ComparePropertiesResult::SelfChange(this_status, message));
} }
} }
} }
} }
Ok(None) Ok(ComparePropertiesResult::NoChange)
} }
pub(crate) fn compare_property_boolean<'b, 's, 'x, R, RG: Fn(R) -> bool>( pub(crate) fn compare_property_boolean<'b, 's, 'x, R, RG: Fn(R) -> bool>(
_source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust_node: R, rust_node: R,
emacs_field: &'x str, emacs_field: &'x str,
rust_value_getter: RG, rust_value_getter: RG,
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> { ) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>> {
// get_property already converts nil to None. // get_property already converts nil to None.
let value = get_property(emacs, emacs_field)?.is_some(); let value = get_property(emacs, emacs_field)?.is_some();
let rust_value = rust_value_getter(rust_node); let rust_value = rust_value_getter(rust_node);
@ -175,8 +190,62 @@ pub(crate) fn compare_property_boolean<'b, 's, 'x, R, RG: Fn(R) -> bool>(
"{} mismatch (emacs != rust) {:?} != {:?}", "{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, value, rust_value emacs_field, value, rust_value
)); ));
Ok(Some((this_status, message))) Ok(ComparePropertiesResult::SelfChange(this_status, message))
} else { } else {
Ok(None) Ok(ComparePropertiesResult::NoChange)
} }
} }
pub(crate) fn compare_property_list_of_ast_nodes<
'b,
's,
'x: 'b + 's,
R,
RV: std::fmt::Debug,
RI: Iterator<Item = RV>,
RG: Fn(R) -> Option<RI>,
>(
source: &'s str,
emacs: &'b Token<'s>,
rust_node: R,
emacs_field: &'x str,
rust_value_getter: RG,
) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>>
where
AstNode<'b, 's>: From<RV>,
{
let value = get_property(emacs, emacs_field)?
.map(Token::as_list)
.map_or(Ok(None), |r| r.map(Some))?;
let rust_value = rust_value_getter(rust_node);
// TODO: Seems we are needlessly coverting to a vec here.
let rust_value: Option<Vec<RV>> = rust_value.map(|it| it.collect());
match (value, rust_value) {
(None, None) => {}
(None, rv @ Some(_)) | (Some(_), rv @ None) => {
let this_status = DiffStatus::Bad;
let message = Some(format!(
"{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, value, rv
));
return Ok(ComparePropertiesResult::SelfChange(this_status, message));
}
(Some(el), Some(rl)) if el.len() != rl.len() => {
let this_status = DiffStatus::Bad;
let message = Some(format!(
"{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, el, rl
));
return Ok(ComparePropertiesResult::SelfChange(this_status, message));
}
(Some(el), Some(rl)) => {
let mut child_status: Vec<DiffEntry<'b, 's>> = Vec::with_capacity(rl.len());
for (e, r) in el.iter().zip(rl) {
child_status.push(compare_ast_node(source, e, r.into())?);
}
let diff_scope = artificial_diff_scope(emacs_field, child_status)?;
return Ok(ComparePropertiesResult::DiffEntry(diff_scope));
}
}
Ok(ComparePropertiesResult::NoChange)
}

View File

@ -8,6 +8,7 @@ use super::compare_field::compare_identity;
use super::compare_field::compare_noop; use super::compare_field::compare_noop;
use super::compare_field::compare_property_always_nil; use super::compare_field::compare_property_always_nil;
use super::compare_field::compare_property_boolean; use super::compare_field::compare_property_boolean;
use super::compare_field::compare_property_list_of_ast_nodes;
use super::compare_field::compare_property_list_of_quoted_string; use super::compare_field::compare_property_list_of_quoted_string;
use super::compare_field::compare_property_quoted_string; use super::compare_field::compare_property_quoted_string;
use super::compare_field::compare_property_unquoted_atom; use super::compare_field::compare_property_unquoted_atom;
@ -23,6 +24,7 @@ use super::util::get_property_boolean;
use super::util::get_property_numeric; use super::util::get_property_numeric;
use super::util::get_property_quoted_string; use super::util::get_property_quoted_string;
use super::util::get_property_unquoted_atom; use super::util::get_property_unquoted_atom;
use crate::compare::compare_field::ComparePropertiesResult;
use crate::compare::compare_field::EmacsField; use crate::compare::compare_field::EmacsField;
use crate::compare::macros::compare_properties; use crate::compare::macros::compare_properties;
use crate::types::AngleLink; use crate::types::AngleLink;
@ -328,8 +330,8 @@ impl<'b, 's> DiffLayer<'b, 's> {
} }
} }
fn artificial_diff_scope<'b, 's>( pub(crate) fn artificial_diff_scope<'b, 's>(
name: &'static str, name: &'s str,
children: Vec<DiffEntry<'b, 's>>, children: Vec<DiffEntry<'b, 's>>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
Ok(DiffLayer { Ok(DiffLayer {
@ -2598,16 +2600,22 @@ fn compare_bold<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? { for diff in compare_properties!(emacs) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2632,16 +2640,22 @@ fn compare_italic<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? { for diff in compare_properties!(emacs) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2666,16 +2680,22 @@ fn compare_underline<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? { for diff in compare_properties!(emacs) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2683,16 +2703,18 @@ fn compare_underline<'b, 's>(
} }
fn compare_verbatim<'b, 's>( fn compare_verbatim<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b Verbatim<'s>, rust: &'b Verbatim<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -2700,16 +2722,22 @@ fn compare_verbatim<'b, 's>(
|r| Some(r.contents), |r| Some(r.contents),
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2717,16 +2745,18 @@ fn compare_verbatim<'b, 's>(
} }
fn compare_code<'b, 's>( fn compare_code<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b Code<'s>, rust: &'b Code<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -2734,16 +2764,22 @@ fn compare_code<'b, 's>(
|r| Some(r.contents), |r| Some(r.contents),
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2768,16 +2804,22 @@ fn compare_strike_through<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!(emacs)? { for diff in compare_properties!(emacs) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2802,7 +2844,8 @@ fn compare_regular_link<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -2844,16 +2887,22 @@ fn compare_regular_link<'b, 's>(
|r| r.get_search_option(), |r| r.get_search_option(),
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2878,7 +2927,8 @@ fn compare_radio_link<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -2911,16 +2961,22 @@ fn compare_radio_link<'b, 's>(
compare_identity, compare_identity,
compare_property_always_nil compare_property_always_nil
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2945,7 +3001,8 @@ fn compare_radio_target<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -2953,16 +3010,22 @@ fn compare_radio_target<'b, 's>(
|r| Some(r.value), |r| Some(r.value),
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -2970,16 +3033,18 @@ fn compare_radio_target<'b, 's>(
} }
fn compare_plain_link<'b, 's>( fn compare_plain_link<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b PlainLink<'s>, rust: &'b PlainLink<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -3021,16 +3086,22 @@ fn compare_plain_link<'b, 's>(
|r| r.search_option, |r| r.search_option,
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -3038,16 +3109,18 @@ fn compare_plain_link<'b, 's>(
} }
fn compare_angle_link<'b, 's>( fn compare_angle_link<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b AngleLink<'s>, rust: &'b AngleLink<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -3089,16 +3162,22 @@ fn compare_angle_link<'b, 's>(
|r| r.get_search_option(), |r| r.get_search_option(),
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -3106,16 +3185,18 @@ fn compare_angle_link<'b, 's>(
} }
fn compare_org_macro<'b, 's>( fn compare_org_macro<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b OrgMacro<'s>, rust: &'b OrgMacro<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -3137,16 +3218,22 @@ fn compare_org_macro<'b, 's>(
}, },
compare_property_list_of_quoted_string compare_property_list_of_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -3154,16 +3241,18 @@ fn compare_org_macro<'b, 's>(
} }
fn compare_entity<'b, 's>( fn compare_entity<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b Entity<'s>, rust: &'b Entity<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -3207,16 +3296,22 @@ fn compare_entity<'b, 's>(
|r| r.use_brackets, |r| r.use_brackets,
compare_property_boolean compare_property_boolean
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -3224,16 +3319,18 @@ fn compare_entity<'b, 's>(
} }
fn compare_latex_fragment<'b, 's>( fn compare_latex_fragment<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b LatexFragment<'s>, rust: &'b LatexFragment<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -3241,16 +3338,22 @@ fn compare_latex_fragment<'b, 's>(
|r| Some(r.value), |r| Some(r.value),
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -3258,16 +3361,18 @@ fn compare_latex_fragment<'b, 's>(
} }
fn compare_export_snippet<'b, 's>( fn compare_export_snippet<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b ExportSnippet<'s>, rust: &'b ExportSnippet<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None; let mut message = None;
assert_no_children(emacs, &mut this_status, &mut message)?; assert_no_children(emacs, &mut this_status, &mut message)?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -3280,16 +3385,22 @@ fn compare_export_snippet<'b, 's>(
|r| r.contents, |r| r.contents,
compare_property_quoted_string compare_property_quoted_string
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -3314,7 +3425,8 @@ fn compare_footnote_reference<'b, 's>(
&mut message, &mut message,
)?; )?;
if let Some((new_status, new_message)) = compare_properties!( for diff in compare_properties!(
source,
emacs, emacs,
rust, rust,
( (
@ -3330,9 +3442,15 @@ fn compare_footnote_reference<'b, 's>(
}), }),
compare_property_unquoted_atom compare_property_unquoted_atom
) )
)? { ) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status; this_status = new_status;
message = new_message; message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
} }
Ok(DiffResult { Ok(DiffResult {
@ -3347,20 +3465,66 @@ fn compare_footnote_reference<'b, 's>(
} }
fn compare_citation<'b, 's>( fn compare_citation<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b Citation<'s>, rust: &'b Citation<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let this_status = DiffStatus::Good; let mut child_status = Vec::new();
let message = None; let mut this_status = DiffStatus::Good;
let mut message = None;
// TODO: Compare :style :prefix :suffix compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
for diff in compare_properties!(
source,
emacs,
rust,
(
EmacsField::Required(":style"),
|r| r.style,
compare_property_quoted_string
),
(
EmacsField::Optional(":prefix"),
|r| if r.prefix.is_empty() {
None
} else {
Some(r.prefix.iter())
},
compare_property_list_of_ast_nodes
),
(
EmacsField::Optional(":suffix"),
|r| if r.suffix.is_empty() {
None
} else {
Some(r.suffix.iter())
},
compare_property_list_of_ast_nodes
)
) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status;
message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
}
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }
@ -3368,20 +3532,59 @@ fn compare_citation<'b, 's>(
} }
fn compare_citation_reference<'b, 's>( fn compare_citation_reference<'b, 's>(
_source: &'s str, source: &'s str,
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b CitationReference<'s>, rust: &'b CitationReference<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let message = None; let mut child_status = Vec::new();
let mut message = None;
// TODO: Compare :key :prefix :suffix assert_no_children(emacs, &mut this_status, &mut message)?;
for diff in compare_properties!(
source,
emacs,
rust,
(
EmacsField::Required(":key"),
|r| Some(r.key),
compare_property_quoted_string
),
(
EmacsField::Optional(":prefix"),
|r| if r.prefix.is_empty() {
None
} else {
Some(r.prefix.iter())
},
compare_property_list_of_ast_nodes
),
(
EmacsField::Optional(":suffix"),
|r| if r.suffix.is_empty() {
None
} else {
Some(r.suffix.iter())
},
compare_property_list_of_ast_nodes
)
) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status;
message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
}
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
name: rust.get_elisp_name(), name: rust.get_elisp_name(),
message, message,
children: Vec::new(), children: child_status,
rust_source: rust.get_source(), rust_source: rust.get_source(),
emacs_token: emacs, emacs_token: emacs,
} }

View File

@ -30,10 +30,9 @@
/// } /// }
/// ``` /// ```
macro_rules! compare_properties { macro_rules! compare_properties {
($emacs:expr, $rust:expr, $(($emacs_field:expr, $rust_value_getter:expr, $compare_fn: expr)),+) => { ($source:expr, $emacs:expr, $rust:expr, $(($emacs_field:expr, $rust_value_getter:expr, $compare_fn: expr)),+) => {
{ {
let mut this_status = DiffStatus::Good; let mut new_status = Vec::new();
let mut message: Option<String> = None;
let children = $emacs.as_list()?; let children = $emacs.as_list()?;
let attributes_child = children let attributes_child = children
.iter() .iter()
@ -44,10 +43,9 @@ macro_rules! compare_properties {
if emacs_keys.contains(":standard-properties") { if emacs_keys.contains(":standard-properties") {
emacs_keys.remove(":standard-properties"); emacs_keys.remove(":standard-properties");
} else { } else {
this_status = DiffStatus::Bad; new_status.push(ComparePropertiesResult::SelfChange(DiffStatus::Bad, Some(format!(
message = Some(format!(
"Emacs token lacks :standard-properties field.", "Emacs token lacks :standard-properties field.",
)); ))));
} }
$( $(
match $emacs_field { match $emacs_field {
@ -58,11 +56,10 @@ macro_rules! compare_properties {
emacs_keys.remove(name); emacs_keys.remove(name);
}, },
EmacsField::Required(name) => { EmacsField::Required(name) => {
this_status = DiffStatus::Bad; new_status.push(ComparePropertiesResult::SelfChange(DiffStatus::Bad, Some(format!(
message = Some(format!(
"Emacs token lacks required field: {}", "Emacs token lacks required field: {}",
name name
)); ))));
}, },
EmacsField::Optional(_name) => {}, EmacsField::Optional(_name) => {},
} }
@ -71,11 +68,10 @@ macro_rules! compare_properties {
if !emacs_keys.is_empty() { if !emacs_keys.is_empty() {
let unexpected_keys: Vec<&str> = emacs_keys.into_iter().collect(); let unexpected_keys: Vec<&str> = emacs_keys.into_iter().collect();
let unexpected_keys = unexpected_keys.join(", "); let unexpected_keys = unexpected_keys.join(", ");
this_status = DiffStatus::Bad; new_status.push(ComparePropertiesResult::SelfChange(DiffStatus::Bad, Some(format!(
message = Some(format!(
"Emacs token had extra field(s): {}", "Emacs token had extra field(s): {}",
unexpected_keys unexpected_keys
)); ))));
} }
$( $(
@ -87,33 +83,23 @@ macro_rules! compare_properties {
name name
}, },
}; };
let result = $compare_fn($emacs, $rust, emacs_name, $rust_value_getter)?; let result = $compare_fn($source, $emacs, $rust, emacs_name, $rust_value_getter)?;
match result { match result {
Some((DiffStatus::Good, _)) => unreachable!("No comparison functions should return Some() when DiffStatus is good."), ComparePropertiesResult::SelfChange(DiffStatus::Good, _) => unreachable!("No comparison functions should return SelfChange() when DiffStatus is good."),
Some((status, msg)) => { ComparePropertiesResult::NoChange => {},
this_status = status; result => {
message = msg; new_status.push(result);
}, }
_ => {}
} }
)+ )+
match this_status { new_status
DiffStatus::Good => {
let result: Result<_, Box<dyn std::error::Error>> = Ok(None);
result
},
_ => {
Ok(Some((this_status, message)))
}
}
} }
}; };
// Default case for when there are no expected properties except for :standard-properties // Default case for when there are no expected properties except for :standard-properties
($emacs:expr) => { ($emacs:expr) => {
{ {
let mut this_status = DiffStatus::Good; let mut new_status = Vec::new();
let mut message: Option<String> = None;
let children = $emacs.as_list()?; let children = $emacs.as_list()?;
let attributes_child = children let attributes_child = children
.iter() .iter()
@ -124,30 +110,20 @@ macro_rules! compare_properties {
if emacs_keys.contains(":standard-properties") { if emacs_keys.contains(":standard-properties") {
emacs_keys.remove(":standard-properties"); emacs_keys.remove(":standard-properties");
} else { } else {
this_status = DiffStatus::Bad; new_status.push(ComparePropertiesResult::SelfChange(DiffStatus::Bad, Some(format!(
message = Some(format!(
"Emacs token lacks :standard-properties field.", "Emacs token lacks :standard-properties field.",
)); ))));
} }
if !emacs_keys.is_empty() { if !emacs_keys.is_empty() {
let unexpected_keys: Vec<&str> = emacs_keys.into_iter().collect(); let unexpected_keys: Vec<&str> = emacs_keys.into_iter().collect();
let unexpected_keys = unexpected_keys.join(", "); let unexpected_keys = unexpected_keys.join(", ");
this_status = DiffStatus::Bad; new_status.push(ComparePropertiesResult::SelfChange(DiffStatus::Bad, Some(format!(
message = Some(format!(
"Emacs token had extra field(s): {}", "Emacs token had extra field(s): {}",
unexpected_keys unexpected_keys
)); ))));
}
match this_status {
DiffStatus::Good => {
let result: Result<_, Box<dyn std::error::Error>> = Ok(None);
result
},
_ => {
Ok(Some((this_status, message)))
}
} }
new_status
} }
}; };
} }

View File

@ -33,11 +33,6 @@ pub(crate) enum ContextElement<'r, 's> {
/// The value stored is the start of the element after the affiliated keywords. In this way, we can ensure that we do not exit an element immediately after the affiliated keyword had been consumed. /// The value stored is the start of the element after the affiliated keywords. In this way, we can ensure that we do not exit an element immediately after the affiliated keyword had been consumed.
HasAffiliatedKeyword(HasAffiliatedKeywordInner<'r, 's>), HasAffiliatedKeyword(HasAffiliatedKeywordInner<'r, 's>),
/// Indicate the position that we started parsing a text section.
///
/// This value is stored because "<<<" is not a valid prefix for text markup UNLESS it is starting a radio target. Likewise "[" is not a valid prefix for text markup UNLESS it is the start of a regular link description.
StartTextSection(OrgSource<'s>),
/// This is just here to use the 's lifetime until I'm sure we can eliminate it from ContextElement. /// This is just here to use the 's lifetime until I'm sure we can eliminate it from ContextElement.
#[allow(dead_code)] #[allow(dead_code)]
Placeholder(PhantomData<&'s str>), Placeholder(PhantomData<&'s str>),
@ -121,7 +116,10 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(self))
)]
pub(crate) fn check_exit_matcher( pub(crate) fn check_exit_matcher(
&'r self, &'r self,
i: OrgSource<'s>, i: OrgSource<'s>,
@ -168,7 +166,10 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn document_end<'b, 'g, 'r, 's>( fn document_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -29,7 +29,10 @@ use crate::parser::util::get_consumed;
use crate::types::AngleLink; use crate::types::AngleLink;
use crate::types::LinkType; use crate::types::LinkType;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn angle_link<'b, 'g, 'r, 's>( pub(crate) fn angle_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -68,7 +71,10 @@ struct PathAngle<'s> {
application: Option<&'s str>, application: Option<&'s str>,
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn path_angle<'b, 'g, 'r, 's>( fn path_angle<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -83,7 +89,10 @@ fn path_angle<'b, 'g, 'r, 's>(
Ok((remaining, path)) Ok((remaining, path))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn path_angle_end<'b, 'g, 'r, 's>( fn path_angle_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -91,7 +100,10 @@ fn path_angle_end<'b, 'g, 'r, 's>(
tag(">")(input) tag(">")(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn parse_angle_link<'b, 'g, 'r, 's>( fn parse_angle_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -102,7 +114,10 @@ fn parse_angle_link<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn parse_file_angle_link<'b, 'g, 'r, 's>( fn parse_file_angle_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -137,7 +152,10 @@ fn parse_file_angle_link<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn parse_protocol_angle_link<'b, 'g, 'r, 's>( fn parse_protocol_angle_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -29,7 +29,10 @@ 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;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -2,6 +2,7 @@ use nom::branch::alt;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::bytes::complete::tag_no_case; use nom::bytes::complete::tag_no_case;
use nom::character::complete::anychar; use nom::character::complete::anychar;
use nom::combinator::map;
use nom::combinator::opt; use nom::combinator::opt;
use nom::combinator::recognize; use nom::combinator::recognize;
use nom::combinator::verify; use nom::combinator::verify;
@ -30,24 +31,27 @@ use crate::parser::util::get_consumed;
use crate::types::Citation; use crate::types::Citation;
use crate::types::Object; use crate::types::Object;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn citation<'b, 'g, 'r, 's>( pub(crate) fn citation<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Citation<'s>> { ) -> Res<OrgSource<'s>, Citation<'s>> {
// TODO: Despite being a standard object, citations cannot exist inside the global prefix/suffix for other citations because citations must contain something that matches @key which is forbidden inside the global prefix/suffix. This TODO is to evaluate if its worth putting in an explicit check for this (which can be easily accomplished by checking the output of `get_bracket_depth()`). I suspect its not worth it because I expect, outside of intentionally crafted inputs, this parser will exit immediately inside a citation since it is unlikely to find the "[cite" substring inside a citation global prefix/suffix. // TODO: Despite being a standard object, citations cannot exist inside the global prefix/suffix for other citations because citations must contain something that matches @key which is forbidden inside the global prefix/suffix. This TODO is to evaluate if its worth putting in an explicit check for this (which can be easily accomplished by checking the output of `get_bracket_depth()`). I suspect its not worth it because I expect, outside of intentionally crafted inputs, this parser will exit immediately inside a citation since it is unlikely to find the "[cite" substring inside a citation global prefix/suffix.
let (remaining, _) = tag_no_case("[cite")(input)?; let (remaining, _) = tag_no_case("[cite")(input)?;
let (remaining, _) = opt(citestyle)(remaining)?; let (remaining, style) = opt(citestyle)(remaining)?;
let (remaining, _) = tag(":")(remaining)?; let (remaining, _) = tag(":")(remaining)?;
let (remaining, _prefix) = let (remaining, prefix) =
must_balance_bracket(opt(parser_with_context!(global_prefix)(context)))(remaining)?; must_balance_bracket(opt(parser_with_context!(global_prefix)(context)))(remaining)?;
let (remaining, _references) = let (remaining, references) =
separated_list1(tag(";"), parser_with_context!(citation_reference)(context))(remaining)?; separated_list1(tag(";"), parser_with_context!(citation_reference)(context))(remaining)?;
let (remaining, _suffix) = must_balance_bracket(opt(tuple(( let (remaining, suffix) = must_balance_bracket(opt(map(
tag(";"), tuple((tag(";"), parser_with_context!(global_suffix)(context))),
parser_with_context!(global_suffix)(context), |(_, suffix)| suffix,
))))(remaining)?; )))(remaining)?;
let (remaining, _) = tag("]")(remaining)?; let (remaining, _) = tag("]")(remaining)?;
let (remaining, _trailing_whitespace) = let (remaining, _trailing_whitespace) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?; maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
@ -56,16 +60,23 @@ pub(crate) fn citation<'b, 'g, 'r, 's>(
remaining, remaining,
Citation { Citation {
source: source.into(), source: source.into(),
style: style.map(Into::<&str>::into),
prefix: prefix.unwrap_or(Vec::new()),
suffix: suffix.unwrap_or(Vec::new()),
children: references,
}, },
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn citestyle<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> { fn citestyle<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
let (remaining, _) = tuple((tag("/"), style))(input)?; map(
let (remaining, _) = opt(tuple((tag("/"), variant)))(remaining)?; tuple((
let source = get_consumed(input, remaining); tag("/"),
Ok((remaining, source)) recognize(tuple((style, opt(tuple((tag("/"), variant)))))),
)),
|(_, style)| style,
)(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
@ -82,7 +93,10 @@ fn variant<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
})))(input) })))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn global_prefix<'b, 'g, 'r, 's>( fn global_prefix<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -108,7 +122,10 @@ fn global_prefix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatche
move |context, input: OrgSource<'_>| _global_prefix_end(context, input, starting_bracket_depth) move |context, input: OrgSource<'_>| _global_prefix_end(context, input, starting_bracket_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _global_prefix_end<'b, 'g, 'r, 's>( fn _global_prefix_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -131,7 +148,10 @@ fn _global_prefix_end<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn global_suffix<'b, 'g, 'r, 's>( fn global_suffix<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -156,7 +176,10 @@ fn global_suffix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatche
move |context, input: OrgSource<'_>| _global_suffix_end(context, input, starting_bracket_depth) move |context, input: OrgSource<'_>| _global_suffix_end(context, input, starting_bracket_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _global_suffix_end<'b, 'g, 'r, 's>( fn _global_suffix_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -186,6 +209,7 @@ mod tests {
use crate::context::GlobalSettings; use crate::context::GlobalSettings;
use crate::context::List; use crate::context::List;
use crate::parser::element_parser::element; use crate::parser::element_parser::element;
use crate::types::CitationReference;
use crate::types::Element; use crate::types::Element;
use crate::types::GetStandardProperties; use crate::types::GetStandardProperties;
@ -213,7 +237,16 @@ mod tests {
.get(0) .get(0)
.expect("Len already asserted to be 1"), .expect("Len already asserted to be 1"),
&Object::Citation(Citation { &Object::Citation(Citation {
source: "[cite:@foo]" source: "[cite:@foo]",
style: None,
prefix: vec![],
suffix: vec![],
children: vec![CitationReference {
source: "@foo",
key: "foo",
prefix: vec![],
suffix: vec![]
}]
}) })
); );
} }

View File

@ -1,6 +1,7 @@
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::character::complete::anychar; use nom::character::complete::anychar;
use nom::combinator::map;
use nom::combinator::not; use nom::combinator::not;
use nom::combinator::opt; use nom::combinator::opt;
use nom::combinator::recognize; use nom::combinator::recognize;
@ -28,47 +29,65 @@ use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
use crate::types::CitationReference; use crate::types::CitationReference;
use crate::types::Object; use crate::types::Object;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn citation_reference<'b, 'g, 'r, 's>( pub(crate) fn citation_reference<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, CitationReference<'s>> { ) -> Res<OrgSource<'s>, CitationReference<'s>> {
let (remaining, _prefix) = let (remaining, prefix) =
must_balance_bracket(opt(parser_with_context!(key_prefix)(context)))(input)?; must_balance_bracket(opt(parser_with_context!(key_prefix)(context)))(input)?;
let (remaining, _key) = parser_with_context!(citation_reference_key)(context)(remaining)?; let (remaining, key) = parser_with_context!(citation_reference_key)(context)(remaining)?;
let (remaining, _suffix) = let (remaining, suffix) =
must_balance_bracket(opt(parser_with_context!(key_suffix)(context)))(remaining)?; must_balance_bracket(opt(parser_with_context!(key_suffix)(context)))(remaining)?;
let without_closing_semi_remaining = remaining;
let (remaining, _closing_semi) = opt(tag(";"))(remaining)?;
let source = get_consumed(input, remaining); let source = get_consumed(input, remaining);
Ok(( Ok((
remaining, without_closing_semi_remaining,
CitationReference { CitationReference {
source: source.into(), source: source.into(),
key: key.into(),
prefix: prefix.unwrap_or(Vec::new()),
suffix: suffix.unwrap_or(Vec::new()),
}, },
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn citation_reference_key<'b, 'g, 'r, 's>( pub(crate) fn citation_reference_key<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {
let (remaining, source) = recognize(tuple(( let (remaining, source) = map(
tuple((
tag("@"), tag("@"),
many1(verify( recognize(many1(verify(
preceded( preceded(
not(parser_with_context!(exit_matcher_parser)(context)), not(parser_with_context!(exit_matcher_parser)(context)),
anychar, anychar,
), ),
|c| { |c| {
WORD_CONSTITUENT_CHARACTERS.contains(*c) || "-.:?~`'/*@+|(){}<>&_^$#%~".contains(*c) WORD_CONSTITUENT_CHARACTERS.contains(*c)
|| "-.:?~`'/*@+|(){}<>&_^$#%~".contains(*c)
}, },
))),
)), )),
)))(input)?; |(_, key)| key,
)(input)?;
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn key_prefix<'b, 'g, 'r, 's>( fn key_prefix<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -89,7 +108,10 @@ fn key_prefix<'b, 'g, 'r, 's>(
Ok((remaining, children)) Ok((remaining, children))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn key_suffix<'b, 'g, 'r, 's>( fn key_suffix<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -114,7 +136,10 @@ fn key_prefix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher {
move |context, input: OrgSource<'_>| _key_prefix_end(context, input, starting_bracket_depth) move |context, input: OrgSource<'_>| _key_prefix_end(context, input, starting_bracket_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _key_prefix_end<'b, 'g, 'r, 's>( fn _key_prefix_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -141,7 +166,10 @@ fn key_suffix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher {
move |context, input: OrgSource<'_>| _key_suffix_end(context, input, starting_bracket_depth) move |context, input: OrgSource<'_>| _key_suffix_end(context, input, starting_bracket_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _key_suffix_end<'b, 'g, 'r, 's>( fn _key_suffix_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -24,7 +24,10 @@ use crate::types::Clock;
use crate::types::ClockStatus; use crate::types::ClockStatus;
use crate::types::Timestamp; use crate::types::Timestamp;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn clock<'b, 'g, 'r, 's>( pub(crate) fn clock<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -55,7 +58,10 @@ pub(crate) fn clock<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn clock_timestamp<'b, 'g, 'r, 's>( fn clock_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -26,7 +26,10 @@ use crate::parser::util::immediate_in_section;
use crate::parser::util::start_of_line; use crate::parser::util::start_of_line;
use crate::types::Comment; use crate::types::Comment;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn comment<'b, 'g, 'r, 's>( pub(crate) fn comment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -69,7 +72,10 @@ pub(crate) fn comment<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn comment_line<'b, 'g, 'r, 's>( fn comment_line<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -15,7 +15,10 @@ 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;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -109,7 +109,7 @@ fn document<'b, 'g, 'r, 's>(
Ok((Into::<&str>::into(remaining), doc)) Ok((Into::<&str>::into(remaining), doc))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
#[allow(dead_code)] #[allow(dead_code)]
fn document_org_source<'b, 'g, 'r, 's>( fn document_org_source<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
@ -186,7 +186,7 @@ fn document_org_source<'b, 'g, 'r, 's>(
Ok((remaining.into(), document)) Ok((remaining.into(), document))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn _document<'b, 'g, 'r, 's>( fn _document<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -35,7 +35,10 @@ use crate::types::Element;
use crate::types::Paragraph; use crate::types::Paragraph;
use crate::types::SetSource; use crate::types::SetSource;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn drawer<'b, 'g, 'r, 's>( pub(crate) fn drawer<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -109,7 +112,10 @@ fn name<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c))(input) take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn drawer_end<'b, 'g, 'r, 's>( fn drawer_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -40,7 +40,10 @@ use crate::types::Element;
use crate::types::Paragraph; use crate::types::Paragraph;
use crate::types::SetSource; use crate::types::SetSource;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn dynamic_block<'b, 'g, 'r, 's>( pub(crate) fn dynamic_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -122,7 +125,10 @@ fn parameters<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
recognize(many_till(anychar, peek(tuple((space0, line_ending)))))(input) recognize(many_till(anychar, peek(tuple((space0, line_ending)))))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn dynamic_block_end<'b, 'g, 'r, 's>( fn dynamic_block_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -51,7 +51,7 @@ pub(crate) const fn element(
move |context, input: OrgSource<'_>| _element(context, input, can_be_paragraph) move |context, input: OrgSource<'_>| _element(context, input, can_be_paragraph)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn _element<'b, 'g, 'r, 's>( fn _element<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -177,7 +177,7 @@ pub(crate) const fn detect_element(
move |context, input: OrgSource<'_>| _detect_element(context, input, can_be_paragraph) move |context, input: OrgSource<'_>| _detect_element(context, input, can_be_paragraph)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn _detect_element<'b, 'g, 'r, 's>( fn _detect_element<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -18,7 +18,10 @@ use crate::error::Res;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::Entity; use crate::types::Entity;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn entity<'b, 'g, 'r, 's>( pub(crate) fn entity<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -45,7 +48,10 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn name<'b, 'g, 'r, 's>( fn name<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -19,7 +19,10 @@ use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::ExportSnippet; use crate::types::ExportSnippet;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn export_snippet<'b, 'g, 'r, 's>( pub(crate) fn export_snippet<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -49,7 +52,10 @@ pub(crate) fn export_snippet<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn backend<'b, 'g, 'r, 's>( fn backend<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -60,7 +66,10 @@ fn backend<'b, 'g, 'r, 's>(
Ok((remaining, backend_name)) Ok((remaining, backend_name))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn contents<'b, 'g, 'r, 's>( fn contents<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -72,7 +81,10 @@ fn contents<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn export_snippet_end<'b, 'g, 'r, 's>( fn export_snippet_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -22,7 +22,10 @@ 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;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -60,7 +63,10 @@ pub(crate) fn fixed_width_area<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn fixed_width_area_line<'b, 'g, 'r, 's>( fn fixed_width_area_line<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -34,7 +34,10 @@ 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;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn footnote_definition<'b, 'g, 'r, 's>( pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -103,7 +106,10 @@ pub(crate) fn label<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s
take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c))(input) take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn footnote_definition_end<'b, 'g, 'r, 's>( fn footnote_definition_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -1,28 +1,36 @@
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::bytes::complete::tag_no_case; use nom::bytes::complete::tag_no_case;
use nom::combinator::all_consuming;
use nom::combinator::map_parser;
use nom::combinator::verify; use nom::combinator::verify;
use nom::multi::many_till; use nom::multi::many1;
use super::org_source::BracketDepth; use super::org_source::BracketDepth;
use super::org_source::OrgSource; use super::org_source::OrgSource;
use super::util::confine_context;
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
use super::util::text_until_exit;
use crate::context::parser_with_context; use crate::context::parser_with_context;
use crate::context::Context;
use crate::context::ContextElement; use crate::context::ContextElement;
use crate::context::ContextMatcher; use crate::context::ContextMatcher;
use crate::context::ExitClass; use crate::context::ExitClass;
use crate::context::ExitMatcherNode; use crate::context::ExitMatcherNode;
use crate::context::List;
use crate::context::RefContext; 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::footnote_definition::label; use crate::parser::footnote_definition::label;
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::get_consumed; use crate::parser::util::get_consumed;
use crate::types::FootnoteReference; use crate::types::FootnoteReference;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn footnote_reference<'b, 'g, 'r, 's>( pub(crate) fn footnote_reference<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -34,7 +42,10 @@ pub(crate) fn footnote_reference<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn anonymous_footnote<'b, 'g, 'r, 's>( fn anonymous_footnote<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -46,13 +57,21 @@ fn anonymous_footnote<'b, 'g, 'r, 's>(
exit_matcher: &exit_with_depth, exit_matcher: &exit_with_depth,
}); });
let parser_context = context.with_additional_node(&parser_context); let parser_context = context.with_additional_node(&parser_context);
let (remaining, (children, _exit_contents)) = verify( let initial_context = ContextElement::document_context();
many_till( let initial_context = Context::new(context.get_global_settings(), List::new(&initial_context));
parser_with_context!(standard_set_object)(&parser_context),
parser_with_context!(exit_matcher_parser)(&parser_context), let (remaining, children) = map_parser(
verify(
parser_with_context!(text_until_exit)(&parser_context),
|text| text.len() > 0,
), ),
|(children, _exit_contents)| !children.is_empty(), confine_context(|i| {
all_consuming(many1(parser_with_context!(standard_set_object)(
&initial_context,
)))(i)
}),
)(remaining)?; )(remaining)?;
let (remaining, _) = tag("]")(remaining)?; let (remaining, _) = tag("]")(remaining)?;
let (remaining, _trailing_whitespace) = let (remaining, _trailing_whitespace) =
@ -68,7 +87,10 @@ fn anonymous_footnote<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn inline_footnote<'b, 'g, 'r, 's>( fn inline_footnote<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -82,13 +104,21 @@ fn inline_footnote<'b, 'g, 'r, 's>(
exit_matcher: &exit_with_depth, exit_matcher: &exit_with_depth,
}); });
let parser_context = context.with_additional_node(&parser_context); let parser_context = context.with_additional_node(&parser_context);
let (remaining, (children, _exit_contents)) = verify( let initial_context = ContextElement::document_context();
many_till( let initial_context = Context::new(context.get_global_settings(), List::new(&initial_context));
parser_with_context!(standard_set_object)(&parser_context),
parser_with_context!(exit_matcher_parser)(&parser_context), let (remaining, children) = map_parser(
verify(
parser_with_context!(text_until_exit)(&parser_context),
|text| text.len() > 0,
), ),
|(children, _exit_contents)| !children.is_empty(), confine_context(|i| {
all_consuming(many1(parser_with_context!(standard_set_object)(
&initial_context,
)))(i)
}),
)(remaining)?; )(remaining)?;
let (remaining, _) = tag("]")(remaining)?; let (remaining, _) = tag("]")(remaining)?;
let (remaining, _trailing_whitespace) = let (remaining, _trailing_whitespace) =
@ -104,7 +134,10 @@ fn inline_footnote<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn footnote_reference_only<'b, 'g, 'r, 's>( fn footnote_reference_only<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -131,7 +164,10 @@ fn footnote_definition_end(starting_bracket_depth: BracketDepth) -> impl Context
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _footnote_definition_end<'b, 'g, 'r, 's>( fn _footnote_definition_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -44,7 +44,10 @@ use crate::types::QuoteBlock;
use crate::types::SetSource; use crate::types::SetSource;
use crate::types::SpecialBlock; use crate::types::SpecialBlock;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn greater_block<'b, 'g, 'r, 's>( pub(crate) fn greater_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -86,7 +89,10 @@ pub(crate) fn greater_block<'b, 'g, 'r, 's>(
Ok((remaining, element)) Ok((remaining, element))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn center_block<'b, 'g, 'r, 's>( 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>,
@ -110,7 +116,10 @@ fn center_block<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn quote_block<'b, 'g, 'r, 's>( 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>,
@ -156,7 +165,10 @@ fn special_block<'s>(
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _special_block<'c, 'b, 'g, 'r, 's>( 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>,
@ -185,7 +197,10 @@ fn _special_block<'c, 'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn greater_block_body<'c, 'b, 'g, 'r, 's>( fn greater_block_body<'c, 'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -254,7 +269,10 @@ fn greater_block_end<'c>(name: &'c str) -> impl ContextMatcher + 'c {
move |context, input: OrgSource<'_>| _greater_block_end(context, input, name) move |context, input: OrgSource<'_>| _greater_block_end(context, input, name)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _greater_block_end<'b, 'g, 'r, 's, 'c>( fn _greater_block_end<'b, 'g, 'r, 's, 'c>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -50,7 +50,10 @@ pub(crate) const fn heading(
move |context, input: OrgSource<'_>| _heading(context, input, parent_level) move |context, input: OrgSource<'_>| _heading(context, input, parent_level)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _heading<'b, 'g, 'r, 's>( fn _heading<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -134,7 +137,10 @@ struct PreHeadline<'s> {
is_footnote_section: bool, is_footnote_section: bool,
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn headline<'b, 'g, 'r, 's>( fn headline<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -211,7 +217,10 @@ fn headline<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn headline_title_end<'b, 'g, 'r, 's>( fn headline_title_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -233,7 +242,10 @@ fn single_tag<'r, 's>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>
})))(input) })))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn heading_keyword<'b, 'g, 'r, 's>( fn heading_keyword<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -293,7 +305,10 @@ fn priority_cookie<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PriorityCooki
Ok((remaining, cookie)) Ok((remaining, cookie))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn headline_level<'b, 'g, 'r, 's>( fn headline_level<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -19,7 +19,7 @@ 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;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", 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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -84,7 +84,7 @@ fn in_buffer_settings_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSou
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(level = "debug"))]
pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>( pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>(
keywords: Vec<Keyword<'sf>>, keywords: Vec<Keyword<'sf>>,
original_settings: &'g GlobalSettings<'g, 's>, original_settings: &'g GlobalSettings<'g, 's>,

View File

@ -25,7 +25,10 @@ use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::InlineBabelCall; use crate::types::InlineBabelCall;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>( pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -46,7 +49,10 @@ pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn name<'b, 'g, 'r, 's>( fn name<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -63,7 +69,10 @@ fn name<'b, 'g, 'r, 's>(
Ok((remaining, name)) Ok((remaining, name))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn name_end<'b, 'g, 'r, 's>( fn name_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -71,7 +80,10 @@ fn name_end<'b, 'g, 'r, 's>(
recognize(one_of("[("))(input) recognize(one_of("[("))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn header<'b, 'g, 'r, 's>( fn header<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -97,7 +109,10 @@ fn header_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher {
move |context, input: OrgSource<'_>| _header_end(context, input, starting_bracket_depth) move |context, input: OrgSource<'_>| _header_end(context, input, starting_bracket_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _header_end<'b, 'g, 'r, 's>( fn _header_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -117,7 +132,10 @@ fn _header_end<'b, 'g, 'r, 's>(
alt((tag("]"), line_ending))(input) alt((tag("]"), line_ending))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn argument<'b, 'g, 'r, 's>( fn argument<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -143,7 +161,10 @@ fn argument_end(starting_parenthesis_depth: BracketDepth) -> impl ContextMatcher
move |context, input: OrgSource<'_>| _argument_end(context, input, starting_parenthesis_depth) move |context, input: OrgSource<'_>| _argument_end(context, input, starting_parenthesis_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _argument_end<'b, 'g, 'r, 's>( fn _argument_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -27,7 +27,10 @@ use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::InlineSourceBlock; use crate::types::InlineSourceBlock;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn inline_source_block<'b, 'g, 'r, 's>( pub(crate) fn inline_source_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -47,7 +50,10 @@ pub(crate) fn inline_source_block<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn lang<'b, 'g, 'r, 's>( fn lang<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -64,7 +70,10 @@ fn lang<'b, 'g, 'r, 's>(
Ok((remaining, lang)) Ok((remaining, lang))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn lang_end<'b, 'g, 'r, 's>( fn lang_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -72,7 +81,10 @@ fn lang_end<'b, 'g, 'r, 's>(
recognize(one_of("[{"))(input) recognize(one_of("[{"))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn header<'b, 'g, 'r, 's>( fn header<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -98,7 +110,10 @@ fn header_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher {
move |context, input: OrgSource<'_>| _header_end(context, input, starting_bracket_depth) move |context, input: OrgSource<'_>| _header_end(context, input, starting_bracket_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _header_end<'b, 'g, 'r, 's>( fn _header_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -118,7 +133,10 @@ fn _header_end<'b, 'g, 'r, 's>(
alt((tag("]"), line_ending))(input) alt((tag("]"), line_ending))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn body<'b, 'g, 'r, 's>( fn body<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -154,7 +172,10 @@ fn body_end(starting_brace_depth: BracketDepth) -> impl ContextMatcher {
move |context, input: OrgSource<'_>| _body_end(context, input, starting_brace_depth) move |context, input: OrgSource<'_>| _body_end(context, input, starting_brace_depth)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _body_end<'b, 'g, 'r, 's>( fn _body_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -89,7 +89,10 @@ fn _filtered_keyword<'s, F: Matcher>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn keyword<'b, 'g, 'r, 's>( pub(crate) fn keyword<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -104,7 +107,10 @@ pub(crate) fn keyword<'b, 'g, 'r, 's>(
Ok((remaining, kw)) Ok((remaining, kw))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn affiliated_keyword_as_regular_keyword<'b, 'g, 'r, 's>( pub(crate) fn affiliated_keyword_as_regular_keyword<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -122,7 +128,10 @@ pub(crate) fn affiliated_keyword<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>,
filtered_keyword(affiliated_key)(input) filtered_keyword(affiliated_key)(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
pub(crate) fn table_formula_keyword<'b, 'g, 'r, 's>( pub(crate) fn table_formula_keyword<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -28,7 +28,10 @@ use crate::parser::util::exit_matcher_parser;
use crate::parser::util::start_of_line; use crate::parser::util::start_of_line;
use crate::types::LatexEnvironment; use crate::types::LatexEnvironment;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -81,7 +84,7 @@ fn contents<F: ContextMatcher>(end_matcher: F) -> impl ContextMatcher {
#[cfg_attr( #[cfg_attr(
feature = "tracing", feature = "tracing",
tracing::instrument(ret, level = "debug", skip(end_matcher)) tracing::instrument(ret, level = "debug", skip(context, end_matcher))
)] )]
fn _contents<'b, 'g, 'r, 's, F: ContextMatcher>( fn _contents<'b, 'g, 'r, 's, F: ContextMatcher>(
end_matcher: F, end_matcher: F,
@ -106,7 +109,10 @@ fn latex_environment_end(current_name: &str) -> impl ContextMatcher {
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _latex_environment_end<'b, 'g, 'r, 's, 'c>( fn _latex_environment_end<'b, 'g, 'r, 's, 'c>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -23,7 +23,10 @@ use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::LatexFragment; use crate::types::LatexFragment;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn latex_fragment<'b, 'g, 'r, 's>( pub(crate) fn latex_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -49,7 +52,10 @@ pub(crate) fn latex_fragment<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn raw_latex_fragment<'b, 'g, 'r, 's>( fn raw_latex_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -62,7 +68,10 @@ fn raw_latex_fragment<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn name<'b, 'g, 'r, 's>( fn name<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -70,7 +79,10 @@ fn name<'b, 'g, 'r, 's>(
alpha1(input) alpha1(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn brackets<'b, 'g, 'r, 's>( fn brackets<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -102,7 +114,10 @@ fn brackets<'b, 'g, 'r, 's>(
Ok((remaining, body)) Ok((remaining, body))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn escaped_parenthesis_fragment<'b, 'g, 'r, 's>( fn escaped_parenthesis_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -121,7 +136,10 @@ fn escaped_parenthesis_fragment<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn escaped_bracket_fragment<'b, 'g, 'r, 's>( fn escaped_bracket_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -140,7 +158,10 @@ fn escaped_bracket_fragment<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn double_dollar_fragment<'b, 'g, 'r, 's>( fn double_dollar_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -160,7 +181,10 @@ fn double_dollar_fragment<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn dollar_char_fragment<'b, 'g, 'r, 's>( fn dollar_char_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -175,7 +199,10 @@ fn dollar_char_fragment<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn pre<'b, 'g, 'r, 's>( fn pre<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -189,7 +216,10 @@ fn pre<'b, 'g, 'r, 's>(
Ok((input, ())) Ok((input, ()))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn post<'b, 'g, 'r, 's>( fn post<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -201,7 +231,10 @@ fn post<'b, 'g, 'r, 's>(
Ok((remaining, ())) Ok((remaining, ()))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn bordered_dollar_fragment<'b, 'g, 'r, 's>( fn bordered_dollar_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -227,7 +260,10 @@ fn bordered_dollar_fragment<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn open_border<'b, 'g, 'r, 's>( fn open_border<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -235,7 +271,10 @@ fn open_border<'b, 'g, 'r, 's>(
recognize(verify(none_of(".,;$"), |c| !c.is_whitespace()))(input) recognize(verify(none_of(".,;$"), |c| !c.is_whitespace()))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn close_border<'b, 'g, 'r, 's>( fn close_border<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -48,7 +48,10 @@ use crate::types::SrcBlock;
use crate::types::SwitchNumberLines; use crate::types::SwitchNumberLines;
use crate::types::VerseBlock; use crate::types::VerseBlock;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -106,7 +109,10 @@ pub(crate) fn verse_block<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -144,7 +150,10 @@ pub(crate) fn comment_block<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -207,7 +216,10 @@ pub(crate) fn example_block<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -253,7 +265,10 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -338,7 +353,10 @@ fn lesser_block_end<'c>(current_name: &'c str) -> impl ContextMatcher + 'c {
move |context, input: OrgSource<'_>| _lesser_block_end(context, input, current_name) move |context, input: OrgSource<'_>| _lesser_block_end(context, input, current_name)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _lesser_block_end<'b, 'g, 'r, 's, 'c>( fn _lesser_block_end<'b, 'g, 'r, 's, 'c>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -364,7 +382,10 @@ const fn lesser_block_begin<'c>(current_name: &'c str) -> impl ContextMatcher +
move |context, input: OrgSource<'_>| _lesser_block_begin(context, input, current_name) move |context, input: OrgSource<'_>| _lesser_block_begin(context, input, current_name)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _lesser_block_begin<'b, 'g, 'r, 's, 'c>( fn _lesser_block_begin<'b, 'g, 'r, 's, 'c>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -594,7 +615,10 @@ fn switch_word<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn content<'b, 'g, 'r, 's>( pub(crate) fn content<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -12,7 +12,10 @@ use crate::error::Res;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::LineBreak; use crate::types::LineBreak;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn line_break<'b, 'g, 'r, 's>( pub(crate) fn line_break<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -30,7 +33,10 @@ pub(crate) fn line_break<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn pre<'b, 'g, 'r, 's>( fn pre<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -31,7 +31,7 @@ use crate::parser::text_markup::text_markup;
use crate::parser::timestamp::timestamp; use crate::parser::timestamp::timestamp;
use crate::types::Object; use crate::types::Object;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn standard_set_object<'b, 'g, 'r, 's>( pub(crate) fn standard_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -46,7 +46,7 @@ pub(crate) fn standard_set_object<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn minimal_set_object<'b, 'g, 'r, 's>( pub(crate) fn minimal_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -61,7 +61,7 @@ pub(crate) fn minimal_set_object<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn standard_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -118,7 +118,7 @@ fn standard_set_object_sans_plain_text<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -139,7 +139,7 @@ fn minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( pub(crate) fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -156,7 +156,7 @@ pub(crate) fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>(
)))); ))));
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn detect_minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn detect_minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -173,7 +173,7 @@ fn detect_minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>(
)))); ))));
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn regular_link_description_set_object<'b, 'g, 'r, 's>( pub(crate) fn regular_link_description_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -191,7 +191,7 @@ pub(crate) fn regular_link_description_set_object<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -220,7 +220,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -237,7 +237,7 @@ fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
)))); ))));
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn table_cell_set_object<'b, 'g, 'r, 's>( pub(crate) fn table_cell_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -252,7 +252,7 @@ pub(crate) fn table_cell_set_object<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -286,7 +286,7 @@ fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>(
Ok((remaining, object)) Ok((remaining, object))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -19,7 +19,10 @@ use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::OrgMacro; use crate::types::OrgMacro;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn org_macro<'b, 'g, 'r, 's>( pub(crate) fn org_macro<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -48,7 +51,10 @@ pub(crate) fn org_macro<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn org_macro_name<'b, 'g, 'r, 's>( fn org_macro_name<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -61,7 +67,10 @@ fn org_macro_name<'b, 'g, 'r, 's>(
Ok((remaining, source)) Ok((remaining, source))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn org_macro_args<'b, 'g, 'r, 's>( fn org_macro_args<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -74,7 +83,10 @@ fn org_macro_args<'b, 'g, 'r, 's>(
Ok((remaining, args)) Ok((remaining, args))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn org_macro_arg<'b, 'g, 'r, 's>( fn org_macro_arg<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -29,7 +29,7 @@ use crate::parser::util::exit_matcher_parser;
use crate::parser::util::start_of_line; use crate::parser::util::start_of_line;
use crate::types::Paragraph; use crate::types::Paragraph;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn paragraph<'b, 'g, 'r, 's>( pub(crate) fn paragraph<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -71,7 +71,7 @@ pub(crate) fn paragraph<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn paragraph_end<'b, 'g, 'r, 's>( fn paragraph_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -44,7 +44,10 @@ use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
use crate::types::LinkType; use crate::types::LinkType;
use crate::types::PlainLink; use crate::types::PlainLink;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn plain_link<'b, 'g, 'r, 's>( pub(crate) fn plain_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -77,7 +80,10 @@ struct PathPlain<'s> {
application: Option<&'s str>, application: Option<&'s str>,
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn pre<'b, 'g, 'r, 's>( fn pre<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -97,7 +103,10 @@ fn pre<'b, 'g, 'r, 's>(
Ok((input, ())) Ok((input, ()))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn post<'b, 'g, 'r, 's>( fn post<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -106,7 +115,10 @@ fn post<'b, 'g, 'r, 's>(
Ok((remaining, ())) Ok((remaining, ()))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn parse_path_plain<'b, 'g, 'r, 's>( fn parse_path_plain<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -167,7 +179,10 @@ pub(crate) fn parse_path_and_search_option_without_search_option<'s>(
map(rest, |path| (path, None))(input) map(rest, |path| (path, None))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn file_path_plain<'b, 'g, 'r, 's>( fn file_path_plain<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -207,7 +222,10 @@ fn file_path_plain<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn protocol_path_plain<'b, 'g, 'r, 's>( fn protocol_path_plain<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -235,7 +253,10 @@ fn protocol_path_plain<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn protocol<'b, 'g, 'r, 's>( pub(crate) fn protocol<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -255,7 +276,10 @@ pub(crate) fn protocol<'b, 'g, 'r, 's>(
)))) ))))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn path_plain<'b, 'g, 'r, 's>( fn path_plain<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -284,7 +308,10 @@ fn path_plain_end(
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn impl_path_plain_end<'b, 'g, 'r, 's>( fn impl_path_plain_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -323,7 +350,10 @@ fn impl_path_plain_end<'b, 'g, 'r, 's>(
)))) ))))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn path_plain_no_parenthesis<'b, 'g, 'r, 's>( fn path_plain_no_parenthesis<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -351,7 +381,10 @@ fn path_plain_no_parenthesis_disallowed_character<'s>(
}))(input) }))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn path_plain_parenthesis<'b, 'g, 'r, 's>( fn path_plain_parenthesis<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -50,7 +50,10 @@ use crate::types::PlainListItemCounter;
use crate::types::PlainListItemPreBlank; use crate::types::PlainListItemPreBlank;
use crate::types::PlainListType; use crate::types::PlainListType;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn detect_plain_list<'b, 'g, 'r, 's>( pub(crate) fn detect_plain_list<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -76,7 +79,10 @@ pub(crate) fn detect_plain_list<'b, 'g, 'r, 's>(
)))); ))));
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn plain_list<'b, 'g, 'r, 's>( pub(crate) fn plain_list<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -164,7 +170,10 @@ pub(crate) fn plain_list<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn plain_list_item<'b, 'g, 'r, 's>( fn plain_list_item<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -294,7 +303,10 @@ enum BulletType {
Unordered, Unordered,
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn bullet<'b, 'g, 'r, 's>( fn bullet<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -318,7 +330,10 @@ fn bullet<'b, 'g, 'r, 's>(
Ok((remaining, (bullet_type, with_space))) Ok((remaining, (bullet_type, with_space)))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn counter<'b, 'g, 'r, 's>( fn counter<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -358,7 +373,10 @@ fn counter_set_value<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PlainListIt
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn plain_list_end<'b, 'g, 'r, 's>( fn plain_list_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -380,7 +398,7 @@ const fn plain_list_item_end(indent_level: IndentationLevel) -> impl ContextMatc
#[cfg_attr( #[cfg_attr(
feature = "tracing", feature = "tracing",
tracing::instrument(ret, level = "debug", skip(line_indented_lte_matcher)) tracing::instrument(ret, level = "debug", skip(context, line_indented_lte_matcher))
)] )]
fn _plain_list_item_end<'b, 'g, 'r, 's>( fn _plain_list_item_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
@ -398,7 +416,10 @@ const fn line_indented_lte(indent_level: IndentationLevel) -> impl ContextMatche
move |context, input: OrgSource<'_>| _line_indented_lte(context, input, indent_level) move |context, input: OrgSource<'_>| _line_indented_lte(context, input, indent_level)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _line_indented_lte<'b, 'g, 'r, 's>( fn _line_indented_lte<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -416,7 +437,10 @@ fn _line_indented_lte<'b, 'g, 'r, 's>(
Ok(matched) Ok(matched)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn item_tag<'b, 'g, 'r, 's>( fn item_tag<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -438,7 +462,10 @@ fn item_tag<'b, 'g, 'r, 's>(
Ok((remaining, children)) Ok((remaining, children))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn item_tag_end<'b, 'g, 'r, 's>( fn item_tag_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -461,7 +488,10 @@ fn item_tag_divider<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s
)))(input) )))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn item_tag_post_gap<'b, 'g, 'r, 's>( fn item_tag_post_gap<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -494,7 +524,10 @@ fn item_checkbox<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, (CheckboxType,
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn detect_contentless_item_contents<'b, 'g, 'r, 's>( fn detect_contentless_item_contents<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -42,7 +42,7 @@ where
#[cfg_attr( #[cfg_attr(
feature = "tracing", feature = "tracing",
tracing::instrument(ret, level = "debug", skip(end_condition)) tracing::instrument(ret, level = "debug", skip(context, end_condition))
)] )]
fn _plain_text<'b, 'g, 'r, 's, F>( fn _plain_text<'b, 'g, 'r, 's, F>(
end_condition: F, end_condition: F,
@ -75,7 +75,10 @@ where
} }
impl<'x> RematchObject<'x> for PlainText<'x> { impl<'x> RematchObject<'x> for PlainText<'x> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn rematch_object<'b, 'g, 'r, 's>( fn rematch_object<'b, 'g, 'r, 's>(
&'x self, &'x self,
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,

View File

@ -19,7 +19,7 @@ use crate::parser::util::start_of_line;
use crate::types::Planning; use crate::types::Planning;
use crate::types::Timestamp; use crate::types::Timestamp;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn planning<'b, 'g, 'r, 's>( pub(crate) fn planning<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -70,7 +70,7 @@ enum PlanningTimestampType {
Closed, Closed,
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn planning_parameter<'b, 'g, 'r, 's>( fn planning_parameter<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -30,7 +30,10 @@ use crate::parser::util::start_of_line;
use crate::types::NodeProperty; use crate::types::NodeProperty;
use crate::types::PropertyDrawer; use crate::types::PropertyDrawer;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn property_drawer<'b, 'g, 'r, 's>( pub(crate) fn property_drawer<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -82,7 +85,10 @@ pub(crate) fn property_drawer<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn property_drawer_end<'b, 'g, 'r, 's>( fn property_drawer_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -96,7 +102,10 @@ fn property_drawer_end<'b, 'g, 'r, 's>(
)))(input) )))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn node_property<'b, 'g, 'r, 's>( fn node_property<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -141,7 +150,10 @@ fn node_property<'b, 'g, 'r, 's>(
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn node_property_name<'b, 'g, 'r, 's>( fn node_property_name<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -166,7 +178,10 @@ fn node_property_name<'b, 'g, 'r, 's>(
Ok((remaining, name)) Ok((remaining, name))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn node_property_name_end<'b, 'g, 'r, 's>( fn node_property_name_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -2,19 +2,23 @@ use nom::branch::alt;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::character::complete::line_ending; use nom::character::complete::line_ending;
use nom::character::complete::space0; use nom::character::complete::space0;
use nom::combinator::all_consuming;
use nom::combinator::consumed; use nom::combinator::consumed;
use nom::combinator::map; use nom::combinator::map_parser;
use nom::combinator::verify; use nom::combinator::verify;
use nom::multi::many_till; use nom::multi::many1;
use super::object_parser::minimal_set_object; use super::object_parser::minimal_set_object;
use super::org_source::OrgSource; use super::org_source::OrgSource;
use super::util::exit_matcher_parser; use super::util::confine_context;
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
use super::util::text_until_exit;
use crate::context::parser_with_context; use crate::context::parser_with_context;
use crate::context::Context;
use crate::context::ContextElement; use crate::context::ContextElement;
use crate::context::ExitClass; use crate::context::ExitClass;
use crate::context::ExitMatcherNode; use crate::context::ExitMatcherNode;
use crate::context::List;
use crate::context::RefContext; use crate::context::RefContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::error::MyError; use crate::error::MyError;
@ -24,7 +28,10 @@ use crate::types::Object;
use crate::types::RadioLink; use crate::types::RadioLink;
use crate::types::RadioTarget; use crate::types::RadioTarget;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn radio_link<'b, 'g, 'r, 's>( pub(crate) fn radio_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -50,7 +57,10 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>(
)))) ))))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn rematch_target<'x, 'b, 'g, 'r, 's>( pub(crate) fn rematch_target<'x, 'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
target: &'x Vec<Object<'x>>, target: &'x Vec<Object<'x>>,
@ -97,31 +107,33 @@ pub(crate) fn rematch_target<'x, 'b, 'g, 'r, 's>(
Ok((remaining, new_matches)) Ok((remaining, new_matches))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn radio_target<'b, 'g, 'r, 's>( pub(crate) fn radio_target<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RadioTarget<'s>> { ) -> Res<OrgSource<'s>, RadioTarget<'s>> {
let (remaining, _opening) = tag("<<<")(input)?; let (remaining, _opening) = tag("<<<")(input)?;
let contexts = [ let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Gamma, class: ExitClass::Gamma,
exit_matcher: &radio_target_end, exit_matcher: &radio_target_end,
}), });
ContextElement::StartTextSection(remaining), let parser_context = context.with_additional_node(&parser_context);
]; let initial_context = ContextElement::document_context();
let parser_context = context.with_additional_node(&contexts[0]); let initial_context = Context::new(context.get_global_settings(), List::new(&initial_context));
let parser_context = parser_context.with_additional_node(&contexts[1]);
let (remaining, (raw_value, children)) = consumed(verify( let (remaining, (raw_value, children)) = consumed(map_parser(
map( verify(
many_till( parser_with_context!(text_until_exit)(&parser_context),
parser_with_context!(minimal_set_object)(&parser_context), |text| text.len() > 0,
parser_with_context!(exit_matcher_parser)(&parser_context),
), ),
|(children, _)| children, confine_context(|i| {
), all_consuming(many1(parser_with_context!(minimal_set_object)(
|children: &Vec<_>| !children.is_empty(), &initial_context,
)))(i)
}),
))(remaining)?; ))(remaining)?;
let (remaining, _closing) = tag(">>>")(remaining)?; let (remaining, _closing) = tag(">>>")(remaining)?;
@ -138,7 +150,10 @@ pub(crate) fn radio_target<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn radio_target_end<'b, 'g, 'r, 's>( fn radio_target_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -8,6 +8,7 @@ use nom::bytes::complete::take;
use nom::bytes::complete::take_till1; use nom::bytes::complete::take_till1;
use nom::bytes::complete::take_until; use nom::bytes::complete::take_until;
use nom::character::complete::anychar; use nom::character::complete::anychar;
use nom::combinator::all_consuming;
use nom::combinator::consumed; use nom::combinator::consumed;
use nom::combinator::eof; use nom::combinator::eof;
use nom::combinator::flat_map; use nom::combinator::flat_map;
@ -18,6 +19,7 @@ use nom::combinator::peek;
use nom::combinator::recognize; use nom::combinator::recognize;
use nom::combinator::rest; use nom::combinator::rest;
use nom::combinator::verify; use nom::combinator::verify;
use nom::multi::many1;
use nom::multi::many1_count; use nom::multi::many1_count;
use nom::multi::many_till; use nom::multi::many_till;
use nom::sequence::tuple; use nom::sequence::tuple;
@ -28,15 +30,17 @@ use super::org_source::BracketDepth;
use super::org_source::OrgSource; use super::org_source::OrgSource;
use super::plain_link::parse_file_and_application; use super::plain_link::parse_file_and_application;
use super::plain_link::protocol; use super::plain_link::protocol;
use super::util::exit_matcher_parser; use super::util::confine_context;
use super::util::get_consumed; use super::util::get_consumed;
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
use super::util::text_until_exit; use super::util::text_until_exit;
use crate::context::parser_with_context; use crate::context::parser_with_context;
use crate::context::Context;
use crate::context::ContextElement; use crate::context::ContextElement;
use crate::context::ContextMatcher; use crate::context::ContextMatcher;
use crate::context::ExitClass; use crate::context::ExitClass;
use crate::context::ExitMatcherNode; use crate::context::ExitMatcherNode;
use crate::context::List;
use crate::context::RefContext; use crate::context::RefContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::error::MyError; use crate::error::MyError;
@ -45,7 +49,10 @@ use crate::types::LinkType;
use crate::types::Object; use crate::types::Object;
use crate::types::RegularLink; use crate::types::RegularLink;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn regular_link<'b, 'g, 'r, 's>( pub(crate) fn regular_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -56,7 +63,10 @@ pub(crate) fn regular_link<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn regular_link_without_description<'b, 'g, 'r, 's>( fn regular_link_without_description<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -81,7 +91,10 @@ fn regular_link_without_description<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn regular_link_with_description<'b, 'g, 'r, 's>( fn regular_link_with_description<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -117,7 +130,10 @@ struct PathReg<'s> {
application: Option<Cow<'s, str>>, application: Option<Cow<'s, str>>,
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn pathreg<'b, 'g, 'r, 's>( fn pathreg<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -136,7 +152,10 @@ fn pathreg<'b, 'g, 'r, 's>(
Ok((remaining, path)) Ok((remaining, path))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn parse_path_reg<'b, 'g, 'r, 's>( fn parse_path_reg<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -192,7 +211,10 @@ enum ParserState {
Percent, Percent,
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn apply_link_templates<'b, 'g, 'r, 's>( fn apply_link_templates<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -252,7 +274,10 @@ fn apply_link_templates<'b, 'g, 'r, 's>(
Some(ret) Some(ret)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn file_path_reg<'b, 'g, 'r, 's>( fn file_path_reg<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -355,7 +380,10 @@ fn code_ref_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn protocol_path_reg<'b, 'g, 'r, 's>( fn protocol_path_reg<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -392,32 +420,41 @@ fn fuzzy_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn description<'b, 'g, 'r, 's>( fn description<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Vec<Object<'s>>> { ) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
let contexts = [ let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Beta, class: ExitClass::Beta,
exit_matcher: &description_end, exit_matcher: &description_end,
}), });
ContextElement::StartTextSection(input), let parser_context = context.with_additional_node(&parser_context);
]; let initial_context = ContextElement::document_context();
let parser_context = context.with_additional_node(&contexts[0]); let initial_context = Context::new(context.get_global_settings(), List::new(&initial_context));
let parser_context = parser_context.with_additional_node(&contexts[1]);
let (remaining, (children, _exit_contents)) = verify( let (remaining, children) = map_parser(
many_till( verify(
parser_with_context!(regular_link_description_set_object)(&parser_context), parser_with_context!(text_until_exit)(&parser_context),
parser_with_context!(exit_matcher_parser)(&parser_context), |text| text.len() > 0,
), ),
|(children, _exit_contents)| !children.is_empty(), confine_context(|i| {
all_consuming(many1(parser_with_context!(
regular_link_description_set_object
)(&initial_context)))(i)
}),
)(input)?; )(input)?;
Ok((remaining, children)) Ok((remaining, children))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn description_end<'b, 'g, 'r, 's>( fn description_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -439,7 +476,10 @@ fn path_reg_end(
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn impl_path_reg_end<'b, 'g, 'r, 's>( fn impl_path_reg_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -24,7 +24,10 @@ use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting;
use crate::types::Element; use crate::types::Element;
use crate::types::Section; use crate::types::Section;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn zeroth_section<'b, 'g, 'r, 's>( pub(crate) fn zeroth_section<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -82,7 +85,10 @@ pub(crate) fn zeroth_section<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn section<'b, 'g, 'r, 's>( pub(crate) fn section<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
mut input: OrgSource<'s>, mut input: OrgSource<'s>,
@ -135,7 +141,10 @@ pub(crate) fn section<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn section_end<'b, 'g, 'r, 's>( fn section_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -12,7 +12,7 @@ use crate::context::RefContext;
use crate::error::Res; use crate::error::Res;
use crate::types::StatisticsCookie; use crate::types::StatisticsCookie;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
pub(crate) fn statistics_cookie<'b, 'g, 'r, 's>( pub(crate) fn statistics_cookie<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -23,7 +23,7 @@ pub(crate) fn statistics_cookie<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn percent_statistics_cookie<'b, 'g, 'r, 's>( fn percent_statistics_cookie<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -44,7 +44,7 @@ fn percent_statistics_cookie<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug", skip(context)))]
fn fraction_statistics_cookie<'b, 'g, 'r, 's>( fn fraction_statistics_cookie<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -46,7 +46,10 @@ pub(crate) fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res<O
Ok((input, ())) Ok((input, ()))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn subscript<'b, 'g, 'r, 's>( pub(crate) fn subscript<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -66,7 +69,10 @@ pub(crate) fn subscript<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn superscript<'b, 'g, 'r, 's>( pub(crate) fn superscript<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -98,7 +104,10 @@ enum ScriptBody<'s> {
WithBraces(Vec<Object<'s>>), WithBraces(Vec<Object<'s>>),
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn script_body<'b, 'g, 'r, 's>( fn script_body<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -120,7 +129,10 @@ fn script_body<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn script_asterisk<'b, 'g, 'r, 's>( fn script_asterisk<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -128,7 +140,10 @@ fn script_asterisk<'b, 'g, 'r, 's>(
tag("*")(input) tag("*")(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn script_alphanum<'b, 'g, 'r, 's>( fn script_alphanum<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -157,7 +172,10 @@ fn end_script_alphanum_character<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>,
Ok((remaining, final_char)) Ok((remaining, final_char))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn script_with_braces<'b, 'g, 'r, 's>( fn script_with_braces<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -185,7 +203,10 @@ fn script_with_braces_end(starting_brace_depth: BracketDepth) -> impl ContextMat
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn _script_with_braces_end<'b, 'g, 'r, 's>( fn _script_with_braces_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -205,7 +226,10 @@ fn _script_with_braces_end<'b, 'g, 'r, 's>(
tag("}")(input) tag("}")(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn script_with_parenthesis<'b, 'g, 'r, 's>( fn script_with_parenthesis<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -36,7 +36,10 @@ use crate::types::TableRow;
/// Parse an org-mode-style table /// Parse an org-mode-style table
/// ///
/// This is not the table.el style. /// This is not the table.el style.
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
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>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -88,7 +91,10 @@ pub(crate) fn detect_table<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
Ok((input, ())) Ok((input, ()))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn table_end<'b, 'g, 'r, 's>( fn table_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -97,7 +103,10 @@ fn table_end<'b, 'g, 'r, 's>(
recognize(tuple((space0, not(tag("|")))))(input) recognize(tuple((space0, not(tag("|")))))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn org_mode_table_row<'b, 'g, 'r, 's>( fn org_mode_table_row<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -108,7 +117,10 @@ fn org_mode_table_row<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn org_mode_table_row_rule<'b, 'g, 'r, 's>( fn org_mode_table_row_rule<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -125,7 +137,10 @@ fn org_mode_table_row_rule<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn org_mode_table_row_regular<'b, 'g, 'r, 's>( fn org_mode_table_row_regular<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -145,7 +160,10 @@ fn org_mode_table_row_regular<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn org_mode_table_cell<'b, 'g, 'r, 's>( fn org_mode_table_cell<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -178,7 +196,10 @@ fn org_mode_table_cell<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn org_mode_table_cell_end<'b, 'g, 'r, 's>( fn org_mode_table_cell_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -20,7 +20,10 @@ use crate::error::Res;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::types::Target; use crate::types::Target;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn target<'b, 'g, 'r, 's>( pub(crate) fn target<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -61,7 +64,10 @@ pub(crate) fn target<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn target_end<'b, 'g, 'r, 's>( fn target_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -1,7 +1,6 @@
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::character::complete::anychar; use nom::character::complete::anychar;
use nom::character::complete::line_ending;
use nom::character::complete::multispace1; use nom::character::complete::multispace1;
use nom::character::complete::one_of; use nom::character::complete::one_of;
use nom::character::complete::space0; use nom::character::complete::space0;
@ -20,6 +19,7 @@ use super::org_source::OrgSource;
use super::radio_link::RematchObject; use super::radio_link::RematchObject;
use super::util::in_object_section; use super::util::in_object_section;
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
use super::util::org_line_ending;
use super::util::start_of_line; use super::util::start_of_line;
use crate::context::parser_with_context; use crate::context::parser_with_context;
use crate::context::ContextElement; use crate::context::ContextElement;
@ -42,7 +42,10 @@ use crate::types::StrikeThrough;
use crate::types::Underline; use crate::types::Underline;
use crate::types::Verbatim; use crate::types::Verbatim;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn text_markup<'b, 'g, 'r, 's>( pub(crate) fn text_markup<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -60,7 +63,10 @@ pub(crate) fn text_markup<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn bold<'b, 'g, 'r, 's>( fn bold<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -76,7 +82,10 @@ fn bold<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn italic<'b, 'g, 'r, 's>( fn italic<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -92,7 +101,10 @@ fn italic<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn underline<'b, 'g, 'r, 's>( fn underline<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -108,7 +120,10 @@ fn underline<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn strike_through<'b, 'g, 'r, 's>( fn strike_through<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -124,7 +139,10 @@ fn strike_through<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn verbatim<'b, 'g, 'r, 's>( fn verbatim<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -140,7 +158,10 @@ fn verbatim<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn code<'b, 'g, 'r, 's>( fn code<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -166,7 +187,10 @@ fn text_markup_object<'c>(
move |context, input: OrgSource<'_>| _text_markup_object(context, input, marker_symbol) move |context, input: OrgSource<'_>| _text_markup_object(context, input, marker_symbol)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _text_markup_object<'b, 'g, 'r, 's, 'c>( fn _text_markup_object<'b, 'g, 'r, 's, 'c>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -229,7 +253,10 @@ fn text_markup_string<'c>(
move |context, input: OrgSource<'_>| _text_markup_string(context, input, marker_symbol) move |context, input: OrgSource<'_>| _text_markup_string(context, input, marker_symbol)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _text_markup_string<'b, 'g, 'r, 's, 'c>( fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -281,9 +308,12 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
Ok((remaining, contents)) Ok((remaining, contents))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn pre<'b, 'g, 'r, 's>( fn pre<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {
if start_of_line(input).is_ok() { if start_of_line(input).is_ok() {
@ -292,16 +322,6 @@ fn pre<'b, 'g, 'r, 's>(
if preceded_by_whitespace(true)(input).is_ok() { if preceded_by_whitespace(true)(input).is_ok() {
return Ok((input, ())); return Ok((input, ()));
} }
let radio_target_start = context
.iter()
.find_map(|c| match c {
ContextElement::StartTextSection(text) => Some(text),
_ => None,
})
.map(|text| text.get_byte_offset());
if Some(input.get_byte_offset()) == radio_target_start {
return Ok((input, ()));
}
let preceding_character = input.get_preceding_character(); let preceding_character = input.get_preceding_character();
match preceding_character { match preceding_character {
// If None, we are at the start of the file which is technically the beginning of a line. // If None, we are at the start of the file which is technically the beginning of a line.
@ -316,12 +336,16 @@ fn pre<'b, 'g, 'r, 's>(
Ok((input, ())) Ok((input, ()))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn post<'b, 'g, 'r, 's>( fn post<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {
let (remaining, _) = alt((recognize(one_of(" \r\n\t-.,;:!?')}[\"\\")), line_ending))(input)?; let (remaining, _) =
alt((recognize(one_of(" \r\n\t-.,;:!?')}[\"\\")), org_line_ending))(input)?;
Ok((remaining, ())) Ok((remaining, ()))
} }
@ -334,7 +358,10 @@ fn text_markup_end<'c>(
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _text_markup_end<'b, 'g, 'r, 's, 'c>( fn _text_markup_end<'b, 'g, 'r, 's, 'c>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -356,7 +383,10 @@ fn _text_markup_end<'b, 'g, 'r, 's, 'c>(
} }
impl<'x> RematchObject<'x> for Bold<'x> { impl<'x> RematchObject<'x> for Bold<'x> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn rematch_object<'b, 'g, 'r, 's>( fn rematch_object<'b, 'g, 'r, 's>(
&'x self, &'x self,
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
@ -376,7 +406,10 @@ impl<'x> RematchObject<'x> for Bold<'x> {
} }
impl<'x> RematchObject<'x> for Italic<'x> { impl<'x> RematchObject<'x> for Italic<'x> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn rematch_object<'b, 'g, 'r, 's>( fn rematch_object<'b, 'g, 'r, 's>(
&'x self, &'x self,
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
@ -396,7 +429,10 @@ impl<'x> RematchObject<'x> for Italic<'x> {
} }
impl<'x> RematchObject<'x> for Underline<'x> { impl<'x> RematchObject<'x> for Underline<'x> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn rematch_object<'b, 'g, 'r, 's>( fn rematch_object<'b, 'g, 'r, 's>(
&'x self, &'x self,
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
@ -416,7 +452,10 @@ impl<'x> RematchObject<'x> for Underline<'x> {
} }
impl<'x> RematchObject<'x> for StrikeThrough<'x> { impl<'x> RematchObject<'x> for StrikeThrough<'x> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn rematch_object<'b, 'g, 'r, 's>( fn rematch_object<'b, 'g, 'r, 's>(
&'x self, &'x self,
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
@ -435,7 +474,10 @@ impl<'x> RematchObject<'x> for StrikeThrough<'x> {
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _rematch_text_markup_object<'b, 'g, 'r, 's, 'x>( fn _rematch_text_markup_object<'b, 'g, 'r, 's, 'x>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -37,7 +37,10 @@ use crate::types::WarningDelay;
use crate::types::WarningDelayType; use crate::types::WarningDelayType;
use crate::types::Year; use crate::types::Year;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn timestamp<'b, 'g, 'r, 's>( pub(crate) fn timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -55,7 +58,10 @@ pub(crate) fn timestamp<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn diary_timestamp<'b, 'g, 'r, 's>( fn diary_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -83,7 +89,10 @@ fn diary_timestamp<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn sexp<'b, 'g, 'r, 's>( fn sexp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -105,7 +114,10 @@ fn sexp<'b, 'g, 'r, 's>(
Ok((remaining, body)) Ok((remaining, body))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn sexp_end<'b, 'g, 'r, 's>( fn sexp_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -113,7 +125,10 @@ fn sexp_end<'b, 'g, 'r, 's>(
alt((tag(")>"), recognize(one_of(">\n"))))(input) alt((tag(")>"), recognize(one_of(">\n"))))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn active_timestamp<'b, 'g, 'r, 's>( fn active_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -164,7 +179,10 @@ fn active_timestamp<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>( pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -215,7 +233,10 @@ pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn active_date_range_timestamp<'b, 'g, 'r, 's>( fn active_date_range_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -247,7 +268,10 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn active_time_range_timestamp<'b, 'g, 'r, 's>( fn active_time_range_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -298,7 +322,10 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>( pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -331,7 +358,10 @@ pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>( pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -382,7 +412,10 @@ pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn date<'b, 'g, 'r, 's>( fn date<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -415,7 +448,10 @@ fn date<'b, 'g, 'r, 's>(
Ok((remaining, date)) Ok((remaining, date))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn dayname<'b, 'g, 'r, 's>( fn dayname<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -437,7 +473,10 @@ fn dayname<'b, 'g, 'r, 's>(
Ok((remaining, body)) Ok((remaining, body))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn dayname_end<'b, 'g, 'r, 's>( fn dayname_end<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -454,7 +493,10 @@ const fn time<'c>(
move |context, input| _time(context, input, allow_rest) move |context, input| _time(context, input, allow_rest)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn _time<'b, 'g, 'r, 's>( fn _time<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -482,7 +524,10 @@ fn _time<'b, 'g, 'r, 's>(
Ok((remaining, time)) Ok((remaining, time))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn time_rest<'b, 'g, 'r, 's>( fn time_rest<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -495,7 +540,10 @@ fn time_rest<'b, 'g, 'r, 's>(
Ok((remaining, body)) Ok((remaining, body))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn active_time_rest_end<'b, 'g, 'r, 's>( fn active_time_rest_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -510,7 +558,10 @@ fn active_time_rest_end<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn inactive_time_rest_end<'b, 'g, 'r, 's>( fn inactive_time_rest_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -525,7 +576,10 @@ fn inactive_time_rest_end<'b, 'g, 'r, 's>(
))(input) ))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
fn time_range_rest_end<'b, 'g, 'r, 's>( fn time_range_rest_end<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -539,7 +593,10 @@ fn time_range_rest_end<'b, 'g, 'r, 's>(
exit_contents exit_contents
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn repeater<'b, 'g, 'r, 's>( fn repeater<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -574,7 +631,10 @@ fn repeater<'b, 'g, 'r, 's>(
)) ))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context))
)]
fn warning_delay<'b, 'g, 'r, 's>( fn warning_delay<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,

View File

@ -1,3 +1,5 @@
use std::fmt::Debug;
use nom::branch::alt; use nom::branch::alt;
use nom::character::complete::anychar; use nom::character::complete::anychar;
use nom::character::complete::line_ending; use nom::character::complete::line_ending;
@ -89,7 +91,10 @@ fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, O
alt((eof, recognize(many0(blank_line))))(input) alt((eof, recognize(many0(blank_line))))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( pub(crate) fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -105,7 +110,10 @@ pub(crate) fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r
Ok((remaining, None)) Ok((remaining, None))
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -118,7 +126,10 @@ pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>(
} }
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( pub(crate) fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -175,7 +186,10 @@ pub(crate) fn non_whitespace_character(input: OrgSource<'_>) -> Res<OrgSource<'_
} }
/// Check that we are at the start of a line /// Check that we are at the start of a line
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn exit_matcher_parser<'b, 'g, 'r, 's>( pub(crate) fn exit_matcher_parser<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -183,7 +197,10 @@ pub(crate) fn exit_matcher_parser<'b, 'g, 'r, 's>(
peek(|i| context.check_exit_matcher(i))(input) peek(|i| context.check_exit_matcher(i))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(context))
)]
pub(crate) fn text_until_exit<'b, 'g, 'r, 's>( pub(crate) fn text_until_exit<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -301,3 +318,28 @@ pub(crate) fn get_has_affiliated_keyword<'b, 'g, 'r, 's>(
} }
None None
} }
/// Reset the input OrgSource as if it was starting a fresh document.
///
/// This is important for making start-of-document, end-of-document, and other context-dependent tests succeed.
pub(crate) fn confine_context<'s, O: Debug, I: Fn(OrgSource<'s>) -> Res<OrgSource<'s>, O>>(
inner: I,
) -> impl Fn(OrgSource<'s>) -> Res<OrgSource<'s>, O> {
move |input| impl_confine_context(input, &inner)
}
/// Reset the input OrgSource as if it was starting a fresh document.
///
/// This is important for making start-of-document, end-of-document, and other context-dependent tests succeed.
#[cfg_attr(
feature = "tracing",
tracing::instrument(ret, level = "debug", skip(inner))
)]
fn impl_confine_context<'s, O: Debug, I: Fn(OrgSource<'s>) -> Res<OrgSource<'s>, O>>(
input: OrgSource<'s>,
inner: I,
) -> Res<OrgSource<'s>, O> {
let raw_str = Into::<&str>::into(input);
let back_to_org_source = Into::<OrgSource<'_>>::into(raw_str);
inner(back_to_org_source)
}

View File

@ -200,11 +200,18 @@ pub struct FootnoteReference<'s> {
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct Citation<'s> { pub struct Citation<'s> {
pub source: &'s str, pub source: &'s str,
pub style: Option<&'s str>,
pub prefix: Vec<Object<'s>>,
pub suffix: Vec<Object<'s>>,
pub children: Vec<CitationReference<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct CitationReference<'s> { pub struct CitationReference<'s> {
pub source: &'s str, pub source: &'s str,
pub key: &'s str,
pub prefix: Vec<Object<'s>>,
pub suffix: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]