From 974bceaac56e54cdbdc279375e81473c5cf63cbc Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 31 Dec 2009 01:09:56 +0000 Subject: Use legacy-header variable for custom header. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1682 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/pandoc.hs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/pandoc.hs') diff --git a/src/pandoc.hs b/src/pandoc.hs index a4a9d2900..125d964c1 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -135,10 +135,10 @@ data Opt = Opt , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX , optCSS :: [String] -- ^ CSS file to link to , optTableOfContents :: Bool -- ^ Include table of contents + , optVariables :: [(String,String)] -- ^ Template variables to set , optIncludeInHeader :: String -- ^ File to include in header , optIncludeBeforeBody :: String -- ^ File to include at top of body , optIncludeAfterBody :: String -- ^ File to include at end of body - , optCustomHeader :: String -- ^ Custom header to use, or "DEFAULT" , optTitlePrefix :: String -- ^ Optional prefix for HTML title , optOutputFile :: String -- ^ Name of output file , optNumberSections :: Bool -- ^ Number sections in LaTeX @@ -173,10 +173,10 @@ defaultOpts = Opt , optParseRaw = False , optCSS = [] , optTableOfContents = False + , optVariables = [] , optIncludeInHeader = "" , optIncludeBeforeBody = "" , optIncludeAfterBody = "" - , optCustomHeader = "DEFAULT" , optTitlePrefix = "" , optOutputFile = "-" -- "-" means stdout , optNumberSections = False @@ -374,9 +374,13 @@ options = , Option "C" ["custom-header"] (ReqArg (\arg opt -> do + hPutStrLn stderr $ + "Warning: The -C/--custom-header is deprecated.\n" ++ + "Please transition to using --template instead." text <- readFile arg - return opt { optCustomHeader = text, - optStandalone = True }) + let newVars = ("legacy-header", text) : optVariables opt + return opt { optVariables = newVars + , optStandalone = True }) "FILENAME") "" -- "File to use for custom header (implies -s)" @@ -530,11 +534,11 @@ main = do , optWriter = writerName , optParseRaw = parseRaw , optCSS = css + , optVariables = variables , optTableOfContents = toc , optIncludeInHeader = includeHeader , optIncludeBeforeBody = includeBefore , optIncludeAfterBody = includeAfter - , optCustomHeader = customHeader , optTitlePrefix = titlePrefix , optOutputFile = outputFile , optNumberSections = numberSections @@ -577,7 +581,7 @@ main = do Just r -> return r Nothing -> error ("Unknown reader: " ++ readerName') - (writer, defaultHeader) <- case (lookup writerName' writers) of + (writer, defaultTemplate) <- case (lookup writerName' writers) of Just (w,h) -> return (w, h) Nothing -> error ("Unknown writer: " ++ writerName') @@ -613,13 +617,13 @@ main = do (\f -> "\n") css - let header = (if customHeader == "DEFAULT" - then defaultHeader - else customHeader) ++ csslink ++ includeHeader + let variables' = [("css", csslink) | not (null css)] ++ + [("header-includes", includeHeader)] ++ + variables let writerOptions = WriterOptions { writerStandalone = standalone', - writerTemplate = "", -- TODO - writerVariables = [], -- TODO - writerHeader = header, + writerTemplate = defaultTemplate, + writerVariables = variables', + writerHeader = defaultTemplate, -- TODO remove writerTitlePrefix = titlePrefix, writerTabStop = tabStop, writerTableOfContents = toc && -- cgit v1.2.3