@@ -138,6 +138,8 @@ data Opt = Opt
138138 , optTableOfContents :: Bool -- ^ Include table of contents
139139 , optTemplate :: String -- ^ Custom template
140140 , optVariables :: [(String,String)] -- ^ Template variables to set
141+ , optBefore :: [String] -- ^ Texts to include before body
142+ , optAfter :: [String] -- ^ Texts to include after body
141143 , optOutputFile :: String -- ^ Name of output file
142144 , optNumberSections :: Bool -- ^ Number sections in LaTeX
143145 , optIncremental :: Bool -- ^ Use incremental lists in S5
@@ -172,6 +174,8 @@ defaultOpts = Opt
172174 , optTableOfContents = False
173175 , optTemplate = ""
174176 , optVariables = []
177+ , optBefore = []
178+ , optAfter = []
175179 , optOutputFile = "-" -- "-" means stdout
176180 , optNumberSections = False
177181 , optIncremental = False
@@ -383,13 +387,8 @@ options =
383387 (ReqArg
384388 (\arg opt -> do
385389 text <- readFile arg
386− let oldvars = optVariables opt
387− let newvars = case lookup "before" oldvars of
388− Nothing -> ("before", text) : oldvars
389− Just b -> ("before", b ++ text) :
390− filter ((/= "before") . fst)
391− oldvars
392− return opt { optVariables = newvars })
390+ let oldBefore = optBefore opt
391+ return opt { optBefore = text : oldBefore })
393392 "FILENAME")
394393 "" -- "File to include before document body"
395394
@@ -397,13 +396,8 @@ options =
397396 (ReqArg
398397 (\arg opt -> do
399398 text <- readFile arg
400− let oldvars = optVariables opt
401− let newvars = case lookup "after" oldvars of
402− Nothing -> ("after", text) : oldvars
403− Just a -> ("after", a ++ text) :
404− filter ((/= "after") . fst)
405− oldvars
406− return opt { optVariables = newvars })
399+ let oldAfter = optAfter opt
400+ return opt { optAfter = text : oldAfter })
407401 "FILENAME")
408402 "" -- "File to include after document body"
409403
@@ -572,6 +566,8 @@ main = do
572566 , optWriter = writerName
573567 , optParseRaw = parseRaw
574568 , optVariables = variables
569+ , optBefore = befores
570+ , optAfter = afters
575571 , optTableOfContents = toc
576572 , optTemplate = template
577573 , optOutputFile = outputFile
@@ -665,6 +661,8 @@ main = do
665661 then defaultTemplate
666662 else template,
667663 writerVariables = variables',
664+ writerIncludeBefore = concat befores,
665+ writerIncludeAfter = concat afters,
668666 writerTabStop = tabStop,
669667 writerTableOfContents = toc &&
670668 writerName' /= "s5",