git.iko.soy/typeable/pandoc
on master help sign in
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`.

commit147ef90fdea29d68693184f07f2a679506a13702 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 17 Nov 2019, 17:21 (7 years ago) parent7969d09
2 files changed+17−16
MANUAL.txt+2−2 src/Text/Pandoc/App/CommandLineOptions.hs+15−14
MANUAL.txt+2−2
@@ -1032,8 +1032,8 @@ header when requesting a document from a URL:
10321032
10331033: Specify *STRING* as a prefix at the beginning of the title
10341034 that appears in the HTML header (but not in the title as it
1035− appears at the beginning of the HTML body). Implies
1036− `--standalone`.
1035+ appears at the beginning of the HTML body). This option
1036+ should normally be used with `--standalone`.
10371037
10381038`-c` *URL*, `--css=`*URL*
10391039
src/Text/Pandoc/App/CommandLineOptions.hs+15−14
@@ -34,7 +34,7 @@ import Data.List (intercalate, sort)
3434import Data.List (isPrefixOf)
3535#endif
3636#endif
37−import Data.Maybe (fromMaybe)
37+import Data.Maybe (fromMaybe, isJust)
3838import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme)
3939import System.Console.GetOpt
4040import System.Environment (getArgs, getProgName)
@@ -89,7 +89,14 @@ parseOptions options' defaults = do
8989 [] -> Nothing
9090 xs -> Just xs
9191 return $ opts{ optInputFiles =
92− map normalizePath <$> (optInputFiles opts <> mbArgs) }
92+ map normalizePath <$> (optInputFiles opts <> mbArgs)
93+ , optStandalone = -- certain other options imply standalone
94+ optStandalone opts ||
95+ isJust (optTemplate opts) ||
96+ optSelfContained opts ||
97+ not (null (optIncludeInHeader opts)) ||
98+ not (null (optIncludeBeforeBody opts)) ||
99+ not (null (optIncludeAfterBody opts)) }
93100
94101latexEngines :: [String]
95102latexEngines = ["pdflatex", "lualatex", "xelatex", "latexmk", "tectonic"]
@@ -184,8 +191,7 @@ options =
184191 , Option "" ["template"]
185192 (ReqArg
186193 (\arg opt ->
187− return opt{ optTemplate = Just (normalizePath arg),
188− optStandalone = True })
194+ return opt{ optTemplate = Just (normalizePath arg) })
189195 "FILE")
190196 "" -- "Use custom template"
191197
@@ -283,24 +289,21 @@ options =
283289 , Option "H" ["include-in-header"]
284290 (ReqArg
285291 (\arg opt -> return opt{ optIncludeInHeader =
286− optIncludeInHeader opt ++ [arg],
287− optStandalone = True })
292+ optIncludeInHeader opt ++ [arg] })
288293 "FILE")
289294 "" -- "File to include at end of header (implies -s)"
290295
291296 , Option "B" ["include-before-body"]
292297 (ReqArg
293298 (\arg opt -> return opt{ optIncludeBeforeBody =
294− optIncludeBeforeBody opt ++ [arg],
295− optStandalone = True })
299+ optIncludeBeforeBody opt ++ [arg] })
296300 "FILE")
297301 "" -- "File to include before document body"
298302
299303 , Option "A" ["include-after-body"]
300304 (ReqArg
301305 (\arg opt -> return opt{ optIncludeAfterBody =
302− optIncludeAfterBody opt ++ [arg],
303− optStandalone = True })
306+ optIncludeAfterBody opt ++ [arg] })
304307 "FILE")
305308 "" -- "File to include after document body"
306309
@@ -406,8 +409,7 @@ options =
406409
407410 , Option "" ["self-contained"]
408411 (NoArg
409− (\opt -> return opt { optSelfContained = True,
410− optStandalone = True }))
412+ (\opt -> return opt { optSelfContained = True }))
411413 "" -- "Make slide shows include all the needed js and css"
412414
413415 , Option "" ["request-header"]
@@ -582,8 +584,7 @@ options =
582584 (\arg opt ->
583585 return opt {
584586 optVariables =
585− setVariable "title-prefix" arg $ optVariables opt,
586− optStandalone = True })
587+ setVariable "title-prefix" arg $ optVariables opt })
587588 "STRING")
588589 "" -- "String to prefix to HTML window title"
589590