From dd009498dddfc91596c048393a8a455355265179 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 8 Oct 2023 16:19:25 -0400 Subject: [PATCH] Switch to using coalesce_whitespace_escaped for macro args. --- src/types/object.rs | 6 ++++-- src/types/util.rs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/types/object.rs b/src/types/object.rs index 1fd8539..59198ef 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -1,7 +1,7 @@ use std::borrow::Borrow; use std::borrow::Cow; -use super::util::coalesce_whitespace; +use super::util::coalesce_whitespace_escaped; use super::util::coalesce_whitespace_if_line_break; use super::util::remove_line_break; use super::util::remove_whitespace_if_line_break; @@ -740,6 +740,8 @@ impl<'s> AngleLink<'s> { impl<'s> OrgMacro<'s> { pub fn get_macro_args<'b>(&'b self) -> impl Iterator> + 'b { - self.macro_args.iter().map(|arg| coalesce_whitespace(*arg)) + self.macro_args + .iter() + .map(|arg| coalesce_whitespace_escaped('\\', |c| ",".contains(c))(*arg)) } } diff --git a/src/types/util.rs b/src/types/util.rs index 6480ed7..d7e998d 100644 --- a/src/types/util.rs +++ b/src/types/util.rs @@ -201,6 +201,7 @@ enum CoalesceWhitespaceIfLineBreakState { /// Removes all whitespace from a string. /// /// Example: "foo bar" => "foobar" and "foo \n bar" => "foobar". +#[allow(dead_code)] pub(crate) fn coalesce_whitespace<'s>(input: &'s str) -> Cow<'s, str> { let mut state = CoalesceWhitespace::Normal; for (offset, c) in input.char_indices() {