@@ -135,10 +135,10 @@ data Opt = Opt
135 , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX
135 , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX
136 , optCSS :: [String] -- ^ CSS file to link to
136 , optCSS :: [String] -- ^ CSS file to link to
137 , optTableOfContents :: Bool -- ^ Include table of contents
137 , optTableOfContents :: Bool -- ^ Include table of contents
138+ , optVariables :: [(String,String)] -- ^ Template variables to set
138 , optIncludeInHeader :: String -- ^ File to include in header
139 , optIncludeInHeader :: String -- ^ File to include in header
139 , optIncludeBeforeBody :: String -- ^ File to include at top of body
140 , optIncludeBeforeBody :: String -- ^ File to include at top of body
140 , optIncludeAfterBody :: String -- ^ File to include at end of body
141 , optIncludeAfterBody :: String -- ^ File to include at end of body
141− , optCustomHeader :: String -- ^ Custom header to use, or "DEFAULT"
142 , optTitlePrefix :: String -- ^ Optional prefix for HTML title
142 , optTitlePrefix :: String -- ^ Optional prefix for HTML title
143 , optOutputFile :: String -- ^ Name of output file
143 , optOutputFile :: String -- ^ Name of output file
144 , optNumberSections :: Bool -- ^ Number sections in LaTeX
144 , optNumberSections :: Bool -- ^ Number sections in LaTeX
@@ -173,10 +173,10 @@ defaultOpts = Opt
173 , optParseRaw = False
173 , optParseRaw = False
174 , optCSS = []
174 , optCSS = []
175 , optTableOfContents = False
175 , optTableOfContents = False
176 , optIncludeInHeader = ""
177 , optIncludeInHeader = ""
177 , optIncludeBeforeBody = ""
178 , optIncludeBeforeBody = ""
178 , optIncludeAfterBody = ""
179 , optIncludeAfterBody = ""
179− , optCustomHeader = "DEFAULT"
180 , optTitlePrefix = ""
180 , optTitlePrefix = ""
181 , optOutputFile = "-" -- "-" means stdout
181 , optOutputFile = "-" -- "-" means stdout
182 , optNumberSections = False
182 , optNumberSections = False
@@ -374,9 +374,13 @@ options =
374 , Option "C" ["custom-header"]
374 , Option "C" ["custom-header"]
376 (\arg opt -> do
376 (\arg opt -> do
378+ "Warning: The -C/--custom-header is deprecated.\n" ++
379+ "Please transition to using --template instead."
377 text <- readFile arg
380 text <- readFile arg
378− return opt { optCustomHeader = text,
381+ let newVars = ("legacy-header", text) : optVariables opt
382+ return opt { optVariables = newVars
379− optStandalone = True })
383+ , optStandalone = True })
380 "FILENAME")
384 "FILENAME")
381 "" -- "File to use for custom header (implies -s)"
385 "" -- "File to use for custom header (implies -s)"
@@ -530,11 +534,11 @@ main = do
530 , optWriter = writerName
534 , optWriter = writerName
531 , optParseRaw = parseRaw
535 , optParseRaw = parseRaw
532 , optCSS = css
536 , optCSS = css
537+ , optVariables = variables
533 , optTableOfContents = toc
538 , optTableOfContents = toc
534 , optIncludeInHeader = includeHeader
539 , optIncludeInHeader = includeHeader
535 , optIncludeBeforeBody = includeBefore
540 , optIncludeBeforeBody = includeBefore
536 , optIncludeAfterBody = includeAfter
541 , optIncludeAfterBody = includeAfter
537− , optCustomHeader = customHeader
538 , optTitlePrefix = titlePrefix
542 , optTitlePrefix = titlePrefix
539 , optOutputFile = outputFile
543 , optOutputFile = outputFile
540 , optNumberSections = numberSections
544 , optNumberSections = numberSections
@@ -577,7 +581,7 @@ main = do
577 Just r -> return r
581 Just r -> return r
578 Nothing -> error ("Unknown reader: " ++ readerName')
582 Nothing -> error ("Unknown reader: " ++ readerName')
580− (writer, defaultHeader) <- case (lookup writerName' writers) of
584+ (writer, defaultTemplate) <- case (lookup writerName' writers) of
581 Just (w,h) -> return (w, h)
585 Just (w,h) -> return (w, h)
582 Nothing -> error ("Unknown writer: " ++ writerName')
586 Nothing -> error ("Unknown writer: " ++ writerName')
@@ -613,13 +617,13 @@ main = do
613 (\f -> "<link rel=\"stylesheet\" href=\"" ++
617 (\f -> "<link rel=\"stylesheet\" href=\"" ++
614 f ++ "\" type=\"text/css\" media=\"all\" />\n")
618 f ++ "\" type=\"text/css\" media=\"all\" />\n")
616− let header = (if customHeader == "DEFAULT"
620+ let variables' = [("css", csslink) | not (null css)] ++
618− else customHeader) ++ csslink ++ includeHeader
621+ [("header-includes", includeHeader)] ++
619 let writerOptions = WriterOptions { writerStandalone = standalone',
623 let writerOptions = WriterOptions { writerStandalone = standalone',
620− writerTemplate = "", -- TODO
624+ writerTemplate = defaultTemplate,
621− writerVariables = [], -- TODO
625+ writerVariables = variables',
622− writerHeader = header,
626+ writerHeader = defaultTemplate, -- TODO remove
623 writerTitlePrefix = titlePrefix,
627 writerTitlePrefix = titlePrefix,
624 writerTabStop = tabStop,
628 writerTabStop = tabStop,
625 writerTableOfContents = toc &&
629 writerTableOfContents = toc &&