Trim the trailing space off keywords with values.
All checks were successful
rust-test Build rust-test has succeeded
rust-build Build rust-build has succeeded

This commit is contained in:
Tom Alexander 2023-09-04 22:15:43 -04:00
parent 1c142b68c6
commit b0392ad6fb
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 14 additions and 10 deletions

View File

@ -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<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::err
#[cfg(not(feature = "compare"))]
fn run_parse_on_file<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::error::Error>> {
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."

View File

@ -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<Document<'s>, String> {
parse_with_settings(input, &GlobalSettings::default())
@ -65,7 +64,6 @@ pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, 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>,

View File

@ -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<OrgSource<'s>, Vec<Keyword<'s>>> {

View File

@ -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::<OrgSource<'_>, CustomError<OrgSource<'_>>>,
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,