aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs17
-rw-r--r--src/Text/Pandoc/Writers/Docbook.hs14
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs21
-rw-r--r--src/Text/Pandoc/Writers/TEI.hs10
4 files changed, 33 insertions, 29 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 8e6faefe2..70bed4961 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -37,7 +37,7 @@ import Text.Pandoc.Walk (query)
import Text.Printf ( printf )
import Data.List ( intercalate, intersperse )
import Data.Char ( ord )
-import Data.Maybe ( catMaybes, fromMaybe )
+import Data.Maybe ( catMaybes )
import Control.Monad.State
import Text.Pandoc.Pretty
import Text.Pandoc.ImageSize
@@ -85,9 +85,9 @@ pandocToConTeXt options (Pandoc meta blocks) = do
$ defField "placelist" (intercalate ("," :: String) $
take (writerTOCDepth options +
case writerTopLevelDivision options of
- Just Part -> 0
- Just Chapter -> 0
- _ -> 1)
+ TopLevelPart -> 0
+ TopLevelChapter -> 0
+ _ -> 1)
["chapter","section","subsection","subsubsection",
"subsubsubsection","subsubsubsubsection"])
$ defField "body" main
@@ -423,10 +423,11 @@ sectionHeader (ident,classes,_) hdrLevel lst = do
contents <- inlineListToConTeXt lst
st <- get
let opts = stOptions st
- let level' = case fromMaybe Section (writerTopLevelDivision opts) of
- Part -> hdrLevel - 2
- Chapter -> hdrLevel - 1
- Section -> hdrLevel
+ let level' = case writerTopLevelDivision opts of
+ TopLevelPart -> hdrLevel - 2
+ TopLevelChapter -> hdrLevel - 1
+ TopLevelSection -> hdrLevel
+ TopLevelDefault -> hdrLevel
let ident' = toLabel ident
let (section, chapter) = if "unnumbered" `elem` classes
then (text "subject", text "title")
diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
index 6dc2c3a4b..278bbdcc8 100644
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -39,7 +39,6 @@ import Text.Pandoc.Templates (renderTemplate')
import Text.Pandoc.Readers.TeXMath
import Data.List ( stripPrefix, isPrefixOf, intercalate, isSuffixOf )
import Data.Char ( toLower )
-import Data.Maybe ( fromMaybe, isNothing )
import Data.Monoid ( Any(..) )
import Text.Pandoc.Highlighting ( languages, languagesByExtension )
import Text.Pandoc.Pretty
@@ -82,14 +81,15 @@ writeDocbook opts (Pandoc meta blocks) =
else Nothing
render' = render colwidth
opts' = if ("/book>" `isSuffixOf` (trimr $ writerTemplate opts) &&
- isNothing (writerTopLevelDivision opts))
- then opts{ writerTopLevelDivision = Just Chapter }
+ TopLevelDefault == writerTopLevelDivision opts)
+ then opts{ writerTopLevelDivision = TopLevelChapter }
else opts
-- The numbering here follows LaTeX's internal numbering
- startLvl = case fromMaybe Section (writerTopLevelDivision opts') of
- Part -> -1
- Chapter -> 0
- Section -> 1
+ startLvl = case writerTopLevelDivision opts' of
+ TopLevelPart -> -1
+ TopLevelChapter -> 0
+ TopLevelSection -> 1
+ TopLevelDefault -> 1
auths' = map (authorToDocbook opts) $ docAuthors meta
meta' = B.setMeta "author" auths' meta
Just metadata = metaToJSON opts
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"
diff --git a/src/Text/Pandoc/Writers/TEI.hs b/src/Text/Pandoc/Writers/TEI.hs
index 4b3a205a1..27f6898c3 100644
--- a/src/Text/Pandoc/Writers/TEI.hs
+++ b/src/Text/Pandoc/Writers/TEI.hs
@@ -36,7 +36,6 @@ import Text.Pandoc.Writers.Shared
import Text.Pandoc.Options
import Text.Pandoc.Templates (renderTemplate')
import Data.List ( stripPrefix, isPrefixOf )
-import Data.Maybe ( fromMaybe )
import Data.Char ( toLower )
import Text.Pandoc.Highlighting ( languages, languagesByExtension )
import Text.Pandoc.Pretty
@@ -61,10 +60,11 @@ writeTEI opts (Pandoc meta blocks) =
then Just $ writerColumns opts
else Nothing
render' = render colwidth
- startLvl = case fromMaybe Section (writerTopLevelDivision opts) of
- Part -> -1
- Chapter -> 0
- Section -> 1
+ startLvl = case writerTopLevelDivision opts of
+ TopLevelPart -> -1
+ TopLevelChapter -> 0
+ TopLevelSection -> 1
+ TopLevelDefault -> 1
auths' = map (authorToTEI opts) $ docAuthors meta
meta' = B.setMeta "author" auths' meta
Just metadata = metaToJSON opts