summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-07 05:43:23 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-07 05:43:23 +0000
commitfdf31cd23d85e9615c891edadb726137150c5384 (patch)
tree09209322e496fdef91f5deae79b2438e1ff60ad9
parent98372ea277e698c44ed192d56fff68a041233315 (diff)
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
-rw-r--r--src/Main.hs10
-rw-r--r--src/Text/Pandoc/Shared.hs24
2 files changed, 23 insertions, 11 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 95b4420c1..d25e38911 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -107,6 +107,7 @@ data Opt = Opt
, optWriter :: String -- ^ Writer format
, optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX
, optCSS :: String -- ^ CSS file to link to
+ , optTableOfContents :: Bool -- ^ Include table of contents
, optIncludeInHeader :: String -- ^ File to include in header
, optIncludeBeforeBody :: String -- ^ File to include at top of body
, optIncludeAfterBody :: String -- ^ File to include at end of body
@@ -133,6 +134,7 @@ defaultOpts = Opt
, optWriter = "" -- null for default writer
, optParseRaw = False
, optCSS = ""
+ , optTableOfContents = False
, optIncludeInHeader = ""
, optIncludeBeforeBody = ""
, optIncludeAfterBody = ""
@@ -230,6 +232,11 @@ options =
"CSS")
"" -- "Link to CSS style sheet"
+ , Option "" ["toc", "table-of-contents"]
+ (NoArg
+ (\opt -> return opt { optTableOfContents = True }))
+ "" -- "Include table of contents"
+
, Option "H" ["include-in-header"]
(ReqArg
(\arg opt -> do
@@ -395,6 +402,7 @@ main = do
, optWriter = writerName
, optParseRaw = parseRaw
, optCSS = css
+ , optTableOfContents = toc
, optIncludeInHeader = includeHeader
, optIncludeBeforeBody = includeBefore
, optIncludeAfterBody = includeAfter
@@ -471,6 +479,8 @@ main = do
writerHeader = header,
writerTitlePrefix = titlePrefix,
writerTabStop = tabStop,
+ writerTableOfContents = toc &&
+ (not strict),
writerS5 = (writerName=="s5"),
writerIncremental = incremental,
writerNumberSections = numberSections,
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 00a467ca4..d0b134534 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -375,6 +375,7 @@ data WriterOptions = WriterOptions
, writerHeader :: String -- ^ Header for the document
, writerIncludeBefore :: String -- ^ String to include before the body
, writerIncludeAfter :: String -- ^ String to include after the body
+ , writerTableOfContents :: Bool -- ^ Include table of contents
, writerS5 :: Bool -- ^ We're writing S5
, writerIncremental :: Bool -- ^ Incremental S5 lists
, writerNumberSections :: Bool -- ^ Number sections in LaTeX
@@ -386,17 +387,18 @@ data WriterOptions = WriterOptions
-- | Default writer options.
defaultWriterOptions =
- WriterOptions { writerStandalone = True,
- writerHeader = "",
- writerTitlePrefix = "",
- writerTabStop = 4,
- writerS5 = False,
- writerIncremental = False,
- writerNumberSections = False,
- writerIncludeBefore = "",
- writerIncludeAfter = "",
- writerStrictMarkdown = False,
- writerReferenceLinks = False }
+ WriterOptions { writerStandalone = True,
+ writerHeader = "",
+ writerTitlePrefix = "",
+ writerTabStop = 4,
+ writerTableOfContents = False,
+ writerS5 = False,
+ writerIncremental = False,
+ writerNumberSections = False,
+ writerIncludeBefore = "",
+ writerIncludeAfter = "",
+ writerStrictMarkdown = False,
+ writerReferenceLinks = False }
--
-- code to lookup reference keys in key table