git.iko.soy/typeable/pandoc
on master help sign in
Added writerTableOfContents to WriterOptions, and added a

--table-of-contents/--toc command-line option to Main.hs. git-svn-id: https://pandoc.googlecode.com/svn/trunk@632 788f1e2b-df1e-0410-8736-df70ead52e1b

commitfdf31cd23d85e9615c891edadb726137150c5384 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 7 Jul 2007, 05:43 (19 years ago) parent98372ea
2 files changed+23−11
src/Main.hs+10 src/Text/Pandoc/Shared.hs+13−11
src/Main.hs+10
@@ -107,6 +107,7 @@ data Opt = Opt
107107 , optWriter :: String -- ^ Writer format
108108 , optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX
109109 , optCSS :: String -- ^ CSS file to link to
110+ , optTableOfContents :: Bool -- ^ Include table of contents
110111 , optIncludeInHeader :: String -- ^ File to include in header
111112 , optIncludeBeforeBody :: String -- ^ File to include at top of body
112113 , optIncludeAfterBody :: String -- ^ File to include at end of body
@@ -133,6 +134,7 @@ defaultOpts = Opt
133134 , optWriter = "" -- null for default writer
134135 , optParseRaw = False
135136 , optCSS = ""
137+ , optTableOfContents = False
136138 , optIncludeInHeader = ""
137139 , optIncludeBeforeBody = ""
138140 , optIncludeAfterBody = ""
@@ -230,6 +232,11 @@ options =
230232 "CSS")
231233 "" -- "Link to CSS style sheet"
232234
235+ , Option "" ["toc", "table-of-contents"]
236+ (NoArg
237+ (\opt -> return opt { optTableOfContents = True }))
238+ "" -- "Include table of contents"
239+
233240 , Option "H" ["include-in-header"]
234241 (ReqArg
235242 (\arg opt -> do
@@ -395,6 +402,7 @@ main = do
395402 , optWriter = writerName
396403 , optParseRaw = parseRaw
397404 , optCSS = css
405+ , optTableOfContents = toc
398406 , optIncludeInHeader = includeHeader
399407 , optIncludeBeforeBody = includeBefore
400408 , optIncludeAfterBody = includeAfter
@@ -471,6 +479,8 @@ main = do
471479 writerHeader = header,
472480 writerTitlePrefix = titlePrefix,
473481 writerTabStop = tabStop,
482+ writerTableOfContents = toc &&
483+ (not strict),
474484 writerS5 = (writerName=="s5"),
475485 writerIncremental = incremental,
476486 writerNumberSections = numberSections,
src/Text/Pandoc/Shared.hs+13−11
@@ -375,6 +375,7 @@ data WriterOptions = WriterOptions
375375 , writerHeader :: String -- ^ Header for the document
376376 , writerIncludeBefore :: String -- ^ String to include before the body
377377 , writerIncludeAfter :: String -- ^ String to include after the body
378+ , writerTableOfContents :: Bool -- ^ Include table of contents
378379 , writerS5 :: Bool -- ^ We're writing S5
379380 , writerIncremental :: Bool -- ^ Incremental S5 lists
380381 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
@@ -386,17 +387,18 @@ data WriterOptions = WriterOptions
386387
387388-- | Default writer options.
388389defaultWriterOptions =
389− WriterOptions { writerStandalone = True,
390− writerHeader = "",
391− writerTitlePrefix = "",
392− writerTabStop = 4,
393− writerS5 = False,
394− writerIncremental = False,
395− writerNumberSections = False,
396− writerIncludeBefore = "",
397− writerIncludeAfter = "",
398− writerStrictMarkdown = False,
399− writerReferenceLinks = False }
390+ WriterOptions { writerStandalone = True,
391+ writerHeader = "",
392+ writerTitlePrefix = "",
393+ writerTabStop = 4,
394+ writerTableOfContents = False,
395+ writerS5 = False,
396+ writerIncremental = False,
397+ writerNumberSections = False,
398+ writerIncludeBefore = "",
399+ writerIncludeAfter = "",
400+ writerStrictMarkdown = False,
401+ writerReferenceLinks = False }
400402
401403--
402404-- code to lookup reference keys in key table