aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App/CommandLineOptions.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-07-19 15:21:39 -0700
committerJohn MacFarlane <[email protected]>2023-07-19 15:21:39 -0700
commitce2b023e13fcae31710da4fbb2ada2d0e8f5f4cc (patch)
tree7a07f6227f966beb69ac794284bac47be9a2e03d /src/Text/Pandoc/App/CommandLineOptions.hs
parenteb090c50ff6dc35e3a2971d831a9832c69db7d8d (diff)
Refine command line option preprocessor and add tests for #8956.
The substantive change here is the `-strue` will now work instead of being interpreted as `-s -true`. This is somewhat ad hoc, but I don't think we'll ever have an output format named `rue`, so it's probably okay.
Diffstat (limited to 'src/Text/Pandoc/App/CommandLineOptions.hs')
-rw-r--r--src/Text/Pandoc/App/CommandLineOptions.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index 22e824ade..e76344088 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -238,8 +238,16 @@ pdfEngines = nubOrd $ map snd engines
preprocessArgs :: [String] -> [String]
preprocessArgs [] = []
preprocessArgs ("--":xs) = "--" : xs -- a bare '--' ends option parsing
+-- note that -strue is interpreted as -strue while
+-- -stmarkdown is interpreted as -s -tmarkdown
preprocessArgs (('-':c:d:cs):xs)
| isShortBooleanOpt c
+ , case toLower <$> (d:cs) of
+ "true" -> True
+ "false" -> True
+ _ -> False
+ = ('-':c:d:cs) : preprocessArgs xs
+ | isShortBooleanOpt c
, isShortOpt d = splitArg (c:d:cs) ++ preprocessArgs xs
preprocessArgs (x:xs) = x : preprocessArgs xs