From 147ef90fdea29d68693184f07f2a679506a13702 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 17 Nov 2019 17:21:55 -0800 Subject: 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`. --- src/Text/Pandoc/App/CommandLineOptions.hs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/Text/Pandoc/App') 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" -- cgit v1.2.3