diff --git a/src/main.rs b/src/main.rs index ece63fe..fd82386 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,8 +14,11 @@ use organic::emacs_parse_file_org_document; use organic::get_emacs_version; #[cfg(feature = "compare")] use organic::get_org_mode_version; +use organic::parser::parse_with_settings; #[cfg(feature = "compare")] use organic::parser::sexp::sexp_with_padding; +use organic::GlobalSettings; +use organic::LocalFileAccessInterface; #[cfg(feature = "tracing")] use crate::init_tracing::init_telemetry; @@ -136,10 +139,6 @@ fn run_parse_on_file>(org_path: P) -> Result<(), Box>(org_path: P) -> Result<(), Box> { - use organic::parser::parse_with_settings; - use organic::GlobalSettings; - use organic::LocalFileAccessInterface; - let org_path = org_path.as_ref(); eprintln!( "This program was built with compare disabled. Only parsing with organic, not comparing." diff --git a/src/parser/document.rs b/src/parser/document.rs index a7c57a3..2ad42a7 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -54,7 +54,6 @@ use crate::types::Section; /// Parse a full org-mode document. /// /// This is the main entry point for Organic. It will parse the full contents of the input string as an org-mode document. -#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[allow(dead_code)] pub fn parse<'s>(input: &'s str) -> Result, String> { parse_with_settings(input, &GlobalSettings::default()) @@ -65,7 +64,6 @@ pub fn parse<'s>(input: &'s str) -> Result, String> { /// This is the secondary entry point for Organic. It will parse the full contents of the input string as an org-mode document starting with the settings you supplied. /// /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO". -#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[allow(dead_code)] pub fn parse_with_settings<'g, 's>( input: &'s str, @@ -86,7 +84,6 @@ pub fn parse_with_settings<'g, 's>( /// Use this entry point when you want to have direct control over the starting context or if you want to use this integrated with other nom parsers. For general-purpose usage, the `parse` and `parse_with_settings` functions are a lot simpler. /// /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO". -#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[allow(dead_code)] pub fn document<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, diff --git a/src/parser/in_buffer_settings.rs b/src/parser/in_buffer_settings.rs index e653e2f..f21dc1a 100644 --- a/src/parser/in_buffer_settings.rs +++ b/src/parser/in_buffer_settings.rs @@ -10,6 +10,7 @@ use super::OrgSource; use crate::error::Res; use crate::types::Keyword; +#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub fn scan_for_in_buffer_settings<'s>( input: OrgSource<'s>, ) -> Res, Vec>> { diff --git a/src/parser/keyword.rs b/src/parser/keyword.rs index 886ec70..3c853b7 100644 --- a/src/parser/keyword.rs +++ b/src/parser/keyword.rs @@ -49,7 +49,11 @@ fn _filtered_keyword<'s, F: Matcher>( // TODO: When key is a member of org-element-parsed-keywords, value can contain the standard set objects, excluding footnote references. let (remaining, (consumed_input, (_, _, parsed_key, _))) = consumed(tuple((space0, tag("#+"), key_parser, tag(":"))))(input)?; - match tuple((space0, alt((line_ending, eof))))(remaining) { + match tuple(( + space0::, CustomError>>, + alt((line_ending, eof)), + ))(remaining) + { Ok((remaining, _)) => { return Ok(( remaining, @@ -60,10 +64,13 @@ fn _filtered_keyword<'s, F: Matcher>( }, )); } - err @ Err(_) => err?, + Err(_) => {} }; let (remaining, _ws) = space1(remaining)?; - let (remaining, parsed_value) = is_not("\r\n")(remaining)?; + let (remaining, parsed_value) = recognize(many_till( + anychar, + peek(tuple((space0, alt((line_ending, eof))))), + ))(remaining)?; let (remaining, _ws) = tuple((space0, alt((line_ending, eof))))(remaining)?; Ok(( remaining,