Use $for$ for header-includes.

Put variables in right order.  We've specified that if they
use -A, -B, -H multiple times, the text appears in the same
order as on the command line.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1722 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2009-12-31 01:15:50 +00:00
parent 7baa79597e
commit fbef848a3a
6 changed files with 34 additions and 21 deletions

View file

@ -347,7 +347,7 @@ options =
(\arg opt ->
case break (`elem` ":=") arg of
(k,_:v) -> do
let newvars = (k, v) : optVariables opt
let newvars = optVariables opt ++ [(k,v)]
return opt{ optVariables = newvars }
_ -> do
hPutStrLn stderr $ "Could not parse `" ++ arg ++ "' as a key/value pair (k=v or k:v)"
@ -358,7 +358,8 @@ options =
, Option "c" ["css"]
(ReqArg
(\arg opt -> do
let newvars = ("css",arg) : optVariables opt
-- add new link to end, so it is included in proper order
let newvars = optVariables opt ++ [("css",arg)]
return opt { optVariables = newvars,
optStandalone = True })
"URL")
@ -368,7 +369,8 @@ options =
(ReqArg
(\arg opt -> do
text <- readFile arg
let newvars = ("header-includes",text) : optVariables opt
-- add new ones to end, so they're included in order specified
let newvars = optVariables opt ++ [("header-includes",text)]
return opt { optVariables = newvars,
optStandalone = True })
"FILENAME")
@ -379,7 +381,8 @@ options =
(\arg opt -> do
text <- readFile arg
let oldBefore = optBefore opt
return opt { optBefore = text : oldBefore })
-- add new text to end, so it is included in proper order
return opt { optBefore = oldBefore ++ [text] })
"FILENAME")
"" -- "File to include before document body"
@ -388,7 +391,8 @@ options =
(\arg opt -> do
text <- readFile arg
let oldAfter = optAfter opt
return opt { optAfter = text : oldAfter })
-- add new text to end, so it is included in proper order
return opt { optAfter = oldAfter ++ [text]})
"FILENAME")
"" -- "File to include after document body"
@ -625,11 +629,7 @@ main = do
variables' <- if writerName' == "s5" && standalone'
then do
inc <- s5HeaderIncludes
return $ case lookup "header-includes" variables of
Nothing -> ("header-includes", inc) : variables
Just a -> ("header-includes", a ++ inc) :
filter ((/= "header-includes") . fst)
variables
return $ ("header-includes", inc) : variables
else return variables
variables'' <- case mathMethod of

View file

@ -71,9 +71,9 @@ after={\blank[medium]},
\protect
$endif$
$if(header-includes)$
$for(header-includes)$
$header-includes$
$endif$
$endfor$
$if(title)$
\doctitle{$title$}

View file

@ -33,9 +33,9 @@ $endif$
$for(css)$
<link rel="stylesheet" href="$css$" type="text/css" />
$endfor$
$if(header-includes)$
$for(header-includes)$
$header-includes$
$endif$
$endfor$
$if(latexmathml-script)$
$latexmathml-script$
$endif$

View file

@ -31,9 +31,9 @@ $if(numbersections)$
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(header-includes)$
$for(header-includes)$
$header-includes$
$endif$
$endfor$
$if(title)$
\title{$title$}

View file

@ -4,10 +4,10 @@ $if(titleblock)$
% $date$
$endif$
$if(header-includes)$
$for(header-includes)$
$header-includes$
$endif$
$endfor$
$if(toc)$
$toc$

View file

@ -1,5 +1,14 @@
$if(titleblock)$
$titleblock$
$if(title)$
$title$
$endif$
$if(authors)$
$authors$
$endif$
$if(date)$
Date: $date$
$endif$
$endif$
$if(math)$
@ -7,8 +16,12 @@ $if(math)$
:format: html latex
$endif$
$if(header-includes)$
$header-includes$
$if(toc)$
.. contents::
$endif$
$for(header-includes)$
$header-includes$
$endfor$
$body$