Switch to using coalesce_whitespace_escaped for macro args.
Some checks failed
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded
rust-foreign-document-test Build rust-foreign-document-test has failed

This commit is contained in:
Tom Alexander 2023-10-08 16:19:25 -04:00
parent 17c745ee71
commit dd009498dd
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 5 additions and 2 deletions

View File

@ -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<Item = Cow<'s, str>> + 'b {
self.macro_args.iter().map(|arg| coalesce_whitespace(*arg))
self.macro_args
.iter()
.map(|arg| coalesce_whitespace_escaped('\\', |c| ",".contains(c))(*arg))
}
}

View File

@ -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() {