From 37bc5ef71286be6d21eab4da1e6a0e80807f01f3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 8 Oct 2023 14:48:29 -0400 Subject: [PATCH] Do not include whitespace at the end of value. --- org_mode_samples/object/macro/whitespace_in_args.org | 4 ++++ src/compare/diff.rs | 2 +- src/parser/org_macro.rs | 2 ++ src/types/object.rs | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 org_mode_samples/object/macro/whitespace_in_args.org diff --git a/org_mode_samples/object/macro/whitespace_in_args.org b/org_mode_samples/object/macro/whitespace_in_args.org new file mode 100644 index 0000000..1b10503 --- /dev/null +++ b/org_mode_samples/object/macro/whitespace_in_args.org @@ -0,0 +1,4 @@ +{{{foo(bar baz)}}} + +{{{foo(bar +baz)}}} diff --git a/src/compare/diff.rs b/src/compare/diff.rs index c105821..3c6da09 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -3082,7 +3082,7 @@ fn compare_org_macro<'b, 's>( ), ( EmacsField::Required(":value"), - |r| Some(r.source), + |r| Some(r.macro_value), compare_property_quoted_string ), ( diff --git a/src/parser/org_macro.rs b/src/parser/org_macro.rs index 093dc31..4cc6e04 100644 --- a/src/parser/org_macro.rs +++ b/src/parser/org_macro.rs @@ -26,6 +26,7 @@ pub(crate) fn org_macro<'b, 'g, 'r, 's>( let (remaining, macro_name) = org_macro_name(context, remaining)?; let (remaining, macro_args) = opt(parser_with_context!(org_macro_args)(context))(remaining)?; let (remaining, _) = tag("}}}")(remaining)?; + let macro_value = get_consumed(input, remaining); let (remaining, _trailing_whitespace) = maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?; @@ -40,6 +41,7 @@ pub(crate) fn org_macro<'b, 'g, 'r, 's>( .into_iter() .map(|arg| arg.into()) .collect(), + macro_value: Into::<&str>::into(macro_value), }, )) } diff --git a/src/types/object.rs b/src/types/object.rs index 01435d4..f27324f 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -150,6 +150,7 @@ pub struct OrgMacro<'s> { pub source: &'s str, pub macro_name: &'s str, pub macro_args: Vec<&'s str>, + pub macro_value: &'s str, } #[derive(Debug, PartialEq)]