summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmneesh Singh <natto@weirdnatto.in>2023-08-26 12:33:21 +0530
committerJohn MacFarlane <jgm@berkeley.edu>2023-08-26 17:16:34 -0700
commite4467ba10c6d793ffe4b598719d3ba882240db97 (patch)
tree7d41d5264d739f809080435d2cc64307b6990ab9
parentf7035d080c617cda3804a7d0932da8283a5c681c (diff)
Org reader: allow escaping commas in macro arguments
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
-rw-r--r--src/Text/Pandoc/Readers/Org/Inlines.hs3
-rw-r--r--test/Tests/Readers/Org/Inline.hs5
2 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
index dd27ad91a..1cb945c1e 100644
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -892,7 +892,8 @@ macro = try $ do
updateState $ \s -> s { orgStateMacroDepth = recursionDepth }
return res
where
- argument = manyChar $ notFollowedBy eoa *> noneOf ","
+ argument = manyChar $ notFollowedBy eoa *> (escapedComma <|> noneOf ",")
+ escapedComma = try $ char '\\' *> oneOf ",\\"
eoa = string ")}}}"
smart :: PandocMonad m => OrgParser m (F Inlines)
diff --git a/test/Tests/Readers/Org/Inline.hs b/test/Tests/Readers/Org/Inline.hs
index 2c01c4a82..b0c56faa4 100644
--- a/test/Tests/Readers/Org/Inline.hs
+++ b/test/Tests/Readers/Org/Inline.hs
@@ -393,6 +393,11 @@ tests =
, "{{{HELLO()}}}"
] =?>
para "Foo Bar"
+ , "Macro called with an escaped comma" =:
+ T.unlines [ "#+MACRO: HELLO Foo $1"
+ , "{{{HELLO(moin\\, niom)}}}"
+ ] =?>
+ para "Foo moin, niom"
, testGroup "Citations" Citation.tests
, testGroup "Footnotes" Note.tests