summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/LaTeX.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert+github@zeitkraut.de>2016-11-27 20:31:04 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2016-11-27 20:31:04 +0100
commit1fc07ff4dae5b3673ac2090d0a52f69afc1f078e (patch)
treeee546210df74e004968a7383d2c62aaa92c9415a /src/Text/Pandoc/Writers/LaTeX.hs
parent08bf8f2e9d1ee2bb522b95df9fb1df37f5919c30 (diff)
Refactor top-level division selection (#3261)
The "default" option is no longer represented as `Nothing` but via a new type constructor, making the `Maybe` wrapper superfluous. The default behavior of using heuristics can now be enabled explicitly by setting `--top-level-division=default`. API change (`Text.Pandoc.Options`): The `Division` type was renamed to `TopLevelDivision`. The `Section`, `Chapter`, and `Part` constructors were renamed to `TopLevelSection`, `TopLevelChapter`, and `TopLevelPart`, respectively. An additional `TopLevelDefault` constructor was added, which is now also the new default value of the `writerTopLevelDivision` field in `WriterOptions`.
Diffstat (limited to 'src/Text/Pandoc/Writers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 3657f3464..d9c9e3621 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -89,9 +89,9 @@ writeLaTeX options document =
stUrl = False, stGraphics = False,
stLHS = False,
stBook = (case writerTopLevelDivision options of
- Just Part -> True
- Just Chapter -> True
- _ -> False),
+ TopLevelPart -> True
+ TopLevelChapter -> True
+ _ -> False),
stCsquotes = False, stHighlighting = False,
stIncremental = writerIncremental options,
stInternalLinks = [], stUsesEuro = False }
@@ -763,15 +763,18 @@ sectionHeader unnumbered ident level lst = do
<> braces (text plain))
book <- gets stBook
opts <- gets stOptions
- let topLevelDivision = fromMaybe (if book then Chapter else Section)
- (writerTopLevelDivision opts)
- let level' = if writerBeamer opts && topLevelDivision < Section
+ let topLevelDivision = if book && writerTopLevelDivision opts == TopLevelDefault
+ then TopLevelChapter
+ else writerTopLevelDivision opts
+ let level' = if writerBeamer opts &&
+ topLevelDivision `elem` [TopLevelPart, TopLevelChapter]
-- beamer has parts but no chapters
then if level == 1 then -1 else level - 1
else case topLevelDivision of
- Part -> level - 2
- Chapter -> level - 1
- Section -> level
+ TopLevelPart -> level - 2
+ TopLevelChapter -> level - 1
+ TopLevelSection -> level
+ TopLevelDefault -> level
let sectionType = case level' of
-1 -> "part"
0 -> "chapter"