git.iko.soy/typeable/pandoc
on master help sign in
Simplified handling of --css; removed optCSS in pandoc.hs.

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

commit5ef0be23755990ca45bfe8694f4ff59cb774292a authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:10 (17 years ago) parentb771051
1 file changed+12−20
src/pandoc.hs+12−20
src/pandoc.hs+12−20
@@ -133,11 +133,9 @@ data Opt = Opt
133133 , optReader :: String -- ^ Reader format
134134 , optWriter :: String -- ^ Writer format
135135 , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX
136− , optCSS :: [String] -- ^ CSS file to link to
137136 , optTableOfContents :: Bool -- ^ Include table of contents
138137 , optTemplate :: String -- ^ Custom template
139138 , optVariables :: [(String,String)] -- ^ Template variables to set
140− , optIncludeInHeader :: String -- ^ File to include in header
141139 , optOutputFile :: String -- ^ Name of output file
142140 , optNumberSections :: Bool -- ^ Number sections in LaTeX
143141 , optIncremental :: Bool -- ^ Use incremental lists in S5
@@ -169,11 +167,9 @@ defaultOpts = Opt
169167 , optReader = "" -- null for default reader
170168 , optWriter = "" -- null for default writer
171169 , optParseRaw = False
172− , optCSS = []
173170 , optTableOfContents = False
174171 , optTemplate = ""
175172 , optVariables = []
176− , optIncludeInHeader = ""
177173 , optOutputFile = "-" -- "-" means stdout
178174 , optNumberSections = False
179175 , optIncremental = False
@@ -355,8 +351,15 @@ options =
355351 , Option "c" ["css"]
356352 (ReqArg
357353 (\arg opt -> do
358− let old = optCSS opt
359− return opt { optCSS = old ++ [arg],
354+ let text' = "<link rel=\"stylesheet\" href=\"" ++ arg ++
355+ "\" type=\"text/css\" />\n"
356+ let oldvars = optVariables opt
357+ let newvars = case lookup "css" oldvars of
358+ Nothing -> ("css", text') : oldvars
359+ Just b -> ("css", b ++ text') :
360+ filter ((/= "css") . fst)
361+ oldvars
362+ return opt { optVariables = newvars,
360363 optStandalone = True })
361364 "URL")
362365 "" -- "Link to CSS style sheet"
@@ -364,9 +367,9 @@ options =
364367 , Option "H" ["include-in-header"]
365368 (ReqArg
366369 (\arg opt -> do
367− let old = optIncludeInHeader opt
368370 text <- readFile arg
369− return opt { optIncludeInHeader = old ++ text,
371+ let newvars = ("header-includes",text) : optVariables opt
372+ return opt { optVariables = newvars,
370373 optStandalone = True })
371374 "FILENAME")
372375 "" -- "File to include at end of header (implies -s)"
@@ -563,11 +566,9 @@ main = do
563566 , optReader = readerName
564567 , optWriter = writerName
565568 , optParseRaw = parseRaw
566− , optCSS = css
567569 , optVariables = variables
568570 , optTableOfContents = toc
569571 , optTemplate = template
570− , optIncludeInHeader = includeHeader
571572 , optOutputFile = outputFile
572573 , optNumberSections = numberSections
573574 , optIncremental = incremental
@@ -639,20 +640,11 @@ main = do
639640 stateColumns = columns,
640641 stateStrict = strict,
641642 stateIndentedCodeClasses = codeBlockClasses }
642− let csslink = if null css
643− then ""
644− else concatMap
645− (\f -> "<link rel=\"stylesheet\" href=\"" ++
646− f ++ "\" type=\"text/css\" media=\"all\" />\n")
647− css
648− let variables' = [("css", csslink) | not (null css)] ++
649− [("header-includes", includeHeader)] ++
650− variables
651643 let writerOptions = WriterOptions { writerStandalone = standalone',
652644 writerTemplate = if null template
653645 then defaultTemplate
654646 else template,
655− writerVariables = variables',
647+ writerVariables = variables,
656648 writerTabStop = tabStop,
657649 writerTableOfContents = toc &&
658650 writerName' /= "s5",