git.iko.soy/typeable/pandoc
on master help sign in
Use legacy-header variable for custom header.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1682 788f1e2b-df1e-0410-8736-df70ead52e1b

commit974bceaac56e54cdbdc279375e81473c5cf63cbc authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:09 (17 years ago) parente037d6a
1 file changed+16−12
src/pandoc.hs+16−12
src/pandoc.hs+16−12
@@ -135,10 +135,10 @@ data Opt = Opt
135135 , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX
136136 , optCSS :: [String] -- ^ CSS file to link to
137137 , optTableOfContents :: Bool -- ^ Include table of contents
138+ , optVariables :: [(String,String)] -- ^ Template variables to set
138139 , optIncludeInHeader :: String -- ^ File to include in header
139140 , optIncludeBeforeBody :: String -- ^ File to include at top of body
140141 , optIncludeAfterBody :: String -- ^ File to include at end of body
141− , optCustomHeader :: String -- ^ Custom header to use, or "DEFAULT"
142142 , optTitlePrefix :: String -- ^ Optional prefix for HTML title
143143 , optOutputFile :: String -- ^ Name of output file
144144 , optNumberSections :: Bool -- ^ Number sections in LaTeX
@@ -173,10 +173,10 @@ defaultOpts = Opt
173173 , optParseRaw = False
174174 , optCSS = []
175175 , optTableOfContents = False
176+ , optVariables = []
176177 , optIncludeInHeader = ""
177178 , optIncludeBeforeBody = ""
178179 , optIncludeAfterBody = ""
179− , optCustomHeader = "DEFAULT"
180180 , optTitlePrefix = ""
181181 , optOutputFile = "-" -- "-" means stdout
182182 , optNumberSections = False
@@ -374,9 +374,13 @@ options =
374374 , Option "C" ["custom-header"]
375375 (ReqArg
376376 (\arg opt -> do
377+ hPutStrLn stderr $
378+ "Warning: The -C/--custom-header is deprecated.\n" ++
379+ "Please transition to using --template instead."
377380 text <- readFile arg
378− return opt { optCustomHeader = text,
379− optStandalone = True })
381+ let newVars = ("legacy-header", text) : optVariables opt
382+ return opt { optVariables = newVars
383+ , optStandalone = True })
380384 "FILENAME")
381385 "" -- "File to use for custom header (implies -s)"
382386
@@ -530,11 +534,11 @@ main = do
530534 , optWriter = writerName
531535 , optParseRaw = parseRaw
532536 , optCSS = css
537+ , optVariables = variables
533538 , optTableOfContents = toc
534539 , optIncludeInHeader = includeHeader
535540 , optIncludeBeforeBody = includeBefore
536541 , optIncludeAfterBody = includeAfter
537− , optCustomHeader = customHeader
538542 , optTitlePrefix = titlePrefix
539543 , optOutputFile = outputFile
540544 , optNumberSections = numberSections
@@ -577,7 +581,7 @@ main = do
577581 Just r -> return r
578582 Nothing -> error ("Unknown reader: " ++ readerName')
579583
580− (writer, defaultHeader) <- case (lookup writerName' writers) of
584+ (writer, defaultTemplate) <- case (lookup writerName' writers) of
581585 Just (w,h) -> return (w, h)
582586 Nothing -> error ("Unknown writer: " ++ writerName')
583587
@@ -613,13 +617,13 @@ main = do
613617 (\f -> "<link rel=\"stylesheet\" href=\"" ++
614618 f ++ "\" type=\"text/css\" media=\"all\" />\n")
615619 css
616− let header = (if customHeader == "DEFAULT"
617− then defaultHeader
618− else customHeader) ++ csslink ++ includeHeader
620+ let variables' = [("css", csslink) | not (null css)] ++
621+ [("header-includes", includeHeader)] ++
622+ variables
619623 let writerOptions = WriterOptions { writerStandalone = standalone',
620− writerTemplate = "", -- TODO
621− writerVariables = [], -- TODO
622− writerHeader = header,
624+ writerTemplate = defaultTemplate,
625+ writerVariables = variables',
626+ writerHeader = defaultTemplate, -- TODO remove
623627 writerTitlePrefix = titlePrefix,
624628 writerTabStop = tabStop,
625629 writerTableOfContents = toc &&