aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-11-17 17:21:55 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-17 17:21:55 -0800
commit147ef90fdea29d68693184f07f2a679506a13702 (patch)
tree16a1a097b69007930a669d2b4766ac6bdc3c3dbd /src/Text/Pandoc
parent7969d09866a35de6334619410fdd966a6c80a532 (diff)
downloadpandoc-147ef90fdea29d68693184f07f2a679506a13702.tar.gz
Ensure that options imply `--standalone` even in defaults file.
Certain options (`--self-contained`, `--include-in-header`, etc.) imply `--standalone`. We now handle this after option parsing so that it affects options specified in defaults files too. Behavior change: `--title-prefix` no longer implies `--standalone`.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/App/CommandLineOptions.hs29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index 1776107ff..bf1619e30 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -34,7 +34,7 @@ import Data.List (intercalate, sort)
import Data.List (isPrefixOf)
#endif
#endif
-import Data.Maybe (fromMaybe)
+import Data.Maybe (fromMaybe, isJust)
import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme)
import System.Console.GetOpt
import System.Environment (getArgs, getProgName)
@@ -89,7 +89,14 @@ parseOptions options' defaults = do
[] -> Nothing
xs -> Just xs
return $ opts{ optInputFiles =
- map normalizePath <$> (optInputFiles opts <> mbArgs) }
+ map normalizePath <$> (optInputFiles opts <> mbArgs)
+ , optStandalone = -- certain other options imply standalone
+ optStandalone opts ||
+ isJust (optTemplate opts) ||
+ optSelfContained opts ||
+ not (null (optIncludeInHeader opts)) ||
+ not (null (optIncludeBeforeBody opts)) ||
+ not (null (optIncludeAfterBody opts)) }
latexEngines :: [String]
latexEngines = ["pdflatex", "lualatex", "xelatex", "latexmk", "tectonic"]
@@ -184,8 +191,7 @@ options =
, Option "" ["template"]
(ReqArg
(\arg opt ->
- return opt{ optTemplate = Just (normalizePath arg),
- optStandalone = True })
+ return opt{ optTemplate = Just (normalizePath arg) })
"FILE")
"" -- "Use custom template"
@@ -283,24 +289,21 @@ options =
, Option "H" ["include-in-header"]
(ReqArg
(\arg opt -> return opt{ optIncludeInHeader =
- optIncludeInHeader opt ++ [arg],
- optStandalone = True })
+ optIncludeInHeader opt ++ [arg] })
"FILE")
"" -- "File to include at end of header (implies -s)"
, Option "B" ["include-before-body"]
(ReqArg
(\arg opt -> return opt{ optIncludeBeforeBody =
- optIncludeBeforeBody opt ++ [arg],
- optStandalone = True })
+ optIncludeBeforeBody opt ++ [arg] })
"FILE")
"" -- "File to include before document body"
, Option "A" ["include-after-body"]
(ReqArg
(\arg opt -> return opt{ optIncludeAfterBody =
- optIncludeAfterBody opt ++ [arg],
- optStandalone = True })
+ optIncludeAfterBody opt ++ [arg] })
"FILE")
"" -- "File to include after document body"
@@ -406,8 +409,7 @@ options =
, Option "" ["self-contained"]
(NoArg
- (\opt -> return opt { optSelfContained = True,
- optStandalone = True }))
+ (\opt -> return opt { optSelfContained = True }))
"" -- "Make slide shows include all the needed js and css"
, Option "" ["request-header"]
@@ -582,8 +584,7 @@ options =
(\arg opt ->
return opt {
optVariables =
- setVariable "title-prefix" arg $ optVariables opt,
- optStandalone = True })
+ setVariable "title-prefix" arg $ optVariables opt })
"STRING")
"" -- "String to prefix to HTML window title"