diff options
author | Albert Krewinkel <albert+github@zeitkraut.de> | 2016-11-27 20:31:04 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-11-27 20:31:04 +0100 |
commit | 1fc07ff4dae5b3673ac2090d0a52f69afc1f078e (patch) | |
tree | ee546210df74e004968a7383d2c62aaa92c9415a /src/Text/Pandoc/Writers/ConTeXt.hs | |
parent | 08bf8f2e9d1ee2bb522b95df9fb1df37f5919c30 (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/ConTeXt.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/ConTeXt.hs | 17 |
1 files changed, 9 insertions, 8 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") |