summaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2016-10-19 13:12:57 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2016-10-19 13:12:57 +0200
commit595a171407debfa67436e13e1390d298a3899e74 (patch)
treef36d85988e33ea8c6b86356d137fd78bb816b2aa /pandoc.hs
parentaca695ab0bb5e18e3a2ea6d7b81d9814885c1b00 (diff)
Add option for top-level division type
The `--chapters` option is replaced with `--top-level-division` which allows users to specify the type as which top-level headers should be output. Possible values are `section` (the default), `chapter`, or `part`. The formats LaTeX, ConTeXt, and Docbook allow `part` as top-level division, TEI only allows to set the `type` attribute on `div` containers. The writers are altered to respect this option in a sensible way.
Diffstat (limited to 'pandoc.hs')
-rw-r--r--pandoc.hs27
1 files changed, 14 insertions, 13 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 5f26c1351..86ca9502f 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -183,8 +183,7 @@ data Opt = Opt
, optHtmlQTags :: Bool -- ^ Use <q> tags in HTML
, optHighlight :: Bool -- ^ Highlight source code
, optHighlightStyle :: Style -- ^ Style to use for highlighted code
- , optChapters :: Bool -- ^ Use chapter for top-level sects
- , optParts :: Bool -- ^ Use parts for top-level sects in latex
+ , optTopLevelDivision :: Division -- ^ Type of the top-level divisions
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
, optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
, optReferenceDocx :: Maybe FilePath -- ^ Path of reference.docx
@@ -249,8 +248,7 @@ defaultOpts = Opt
, optHtmlQTags = False
, optHighlight = True
, optHighlightStyle = pygments
- , optChapters = False
- , optParts = False
+ , optTopLevelDivision = Section
, optHTMLMathMethod = PlainMath
, optReferenceODT = Nothing
, optReferenceDocx = Nothing
@@ -608,13 +606,18 @@ options =
, Option "" ["chapters"]
(NoArg
- (\opt -> return opt { optChapters = True }))
+ (\opt -> do warn $ "--chapters is deprecated. " ++
+ "Use --top-level-divison=chapter instead."
+ return opt { optTopLevelDivision = Chapter }))
"" -- "Use chapter for top-level sections in LaTeX, DocBook"
- , Option "" ["parts"]
- (NoArg
- (\opt -> return opt { optParts = True }))
- "" -- "Use part for top-level sections in LaTeX"
+ , Option "" ["top-level-division"]
+ (ReqArg
+ (\arg opt -> case safeRead (uppercaseFirstLetter arg) of
+ Just dvsn -> return opt { optTopLevelDivision = dvsn }
+ _ -> err 76 "could not parse top-level division")
+ "[section|chapter|part]")
+ "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"
, Option "N" ["number-sections"]
(NoArg
@@ -1129,9 +1132,8 @@ convertWithOpts opts args = do
, optHtmlQTags = htmlQTags
, optHighlight = highlight
, optHighlightStyle = highlightStyle
- , optChapters = chapters
+ , optTopLevelDivision = topLevelDivision
, optHTMLMathMethod = mathMethod'
- , optParts = parts
, optReferenceODT = referenceODT
, optReferenceDocx = referenceDocx
, optEpubStylesheet = epubStylesheet
@@ -1394,8 +1396,7 @@ convertWithOpts opts args = do
writerUserDataDir = datadir,
writerHtml5 = html5,
writerHtmlQTags = htmlQTags,
- writerChapters = chapters,
- writerParts = parts,
+ writerTopLevelDivision = topLevelDivision,
writerListings = listings,
writerBeamer = False,
writerSlideLevel = slideLevel,