summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOliver Matthews <oliver@codersoffortune.net>2016-09-06 21:43:45 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2016-09-06 21:43:45 +0200
commit23fb52ef7d0357a0e8abc391f6590e5cbfd606b0 (patch)
treef4827c6774e771977baaf9feaff6685a46fbf120 /src
parent4a2a7a21e5e8bf0d11abd214d372729eb9eb8d0c (diff)
Add --parts command line option to LaTeX writer.
Add --parts command line argument. This only effects LaTeX writer, and only for non-beamer output formats. It changes the output levels so the top level is 'part', the next 'chapter' and then into sections.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Options.hs2
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs27
2 files changed, 19 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 39d314974..856fa259f 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -374,6 +374,7 @@ data WriterOptions = WriterOptions
, writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
, writerSlideLevel :: Maybe Int -- ^ Force header level of slides
, writerChapters :: Bool -- ^ Use "chapter" for top-level sects
+ , writerParts :: Bool -- ^ Use "part" for top-level sects in LaTeX
, writerListings :: Bool -- ^ Use listings package for code
, writerHighlight :: Bool -- ^ Highlight source code
, writerHighlightStyle :: Style -- ^ Style to use for highlighting
@@ -422,6 +423,7 @@ instance Default WriterOptions where
, writerBeamer = False
, writerSlideLevel = Nothing
, writerChapters = False
+ , writerParts = False
, writerListings = False
, writerHighlight = False
, writerHighlightStyle = pygments
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 517460f5d..33e4ffbb1 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -750,18 +750,25 @@ sectionHeader unnumbered ident level lst = do
<> braces (text plain))
book <- gets stBook
opts <- gets stOptions
- let level' = if book || writerChapters opts then level - 1 else level
+ let level' = case level of
+ 1 | writerParts opts -> 0
+ | writerBeamer opts -> 0
+ | book || writerChapters opts -> 1
+ | otherwise -> 2
+ _ | writerParts opts -> level - 1
+ | book || writerChapters opts -> level
+ | otherwise -> level + 1
let sectionType = case level' of
- 0 | writerBeamer opts -> "part"
- | otherwise -> "chapter"
- 1 -> "section"
- 2 -> "subsection"
- 3 -> "subsubsection"
- 4 -> "paragraph"
- 5 -> "subparagraph"
+ 0 -> "part"
+ 1 -> "chapter"
+ 2 -> "section"
+ 3 -> "subsection"
+ 4 -> "subsubsection"
+ 5 -> "paragraph"
+ 6 -> "subparagraph"
_ -> ""
inQuote <- gets stInQuote
- let prefix = if inQuote && level' >= 4
+ let prefix = if inQuote && level' >= 5
then text "\\mbox{}%"
-- needed for \paragraph, \subparagraph in quote environment
-- see http://tex.stackexchange.com/questions/169830/
@@ -770,7 +777,7 @@ sectionHeader unnumbered ident level lst = do
let star = if unnumbered && level < 4 then text "*" else empty
let stuffing = star <> optional <> contents
stuffing' <- hypertarget ident $ text ('\\':sectionType) <> stuffing <> lab
- return $ if level' > 5
+ return $ if level' > 6
then txt
else prefix $$ stuffing'
$$ if unnumbered