aboutsummaryrefslogtreecommitdiff
path: root/tests/Tests/Writers
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 /tests/Tests/Writers
parent08bf8f2e9d1ee2bb522b95df9fb1df37f5919c30 (diff)
downloadpandoc-1fc07ff4dae5b3673ac2090d0a52f69afc1f078e.tar.gz
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 'tests/Tests/Writers')
-rw-r--r--tests/Tests/Writers/Docbook.hs28
-rw-r--r--tests/Tests/Writers/LaTeX.hs39
2 files changed, 52 insertions, 15 deletions
diff --git a/tests/Tests/Writers/Docbook.hs b/tests/Tests/Writers/Docbook.hs
index f2a1e9d7b..a288242dc 100644
--- a/tests/Tests/Writers/Docbook.hs
+++ b/tests/Tests/Writers/Docbook.hs
@@ -236,11 +236,13 @@ tests = [ testGroup "line blocks"
<> header 2 (text "header2")
<> header 3 (text "header3")
- docbookTopLevelDiv :: (ToPandoc a) => Division -> a -> String
+ docbookTopLevelDiv :: (ToPandoc a)
+ => TopLevelDivision -> a -> String
docbookTopLevelDiv division =
- docbookWithOpts def{ writerTopLevelDivision = Just division }
+ docbookWithOpts def{ writerTopLevelDivision = division }
in
- [ test (docbookTopLevelDiv Section) "sections as top-level" $ headers =?>
+ [ test (docbookTopLevelDiv TopLevelSection) "sections as top-level" $
+ headers =?>
unlines [ "<sect1>"
, " <title>header1</title>"
, " <sect2>"
@@ -253,7 +255,8 @@ tests = [ testGroup "line blocks"
, " </sect2>"
, "</sect1>"
]
- , test (docbookTopLevelDiv Chapter) "chapters as top-level" $ headers =?>
+ , test (docbookTopLevelDiv TopLevelChapter) "chapters as top-level" $
+ headers =?>
unlines [ "<chapter>"
, " <title>header1</title>"
, " <sect1>"
@@ -266,7 +269,8 @@ tests = [ testGroup "line blocks"
, " </sect1>"
, "</chapter>"
]
- , test (docbookTopLevelDiv Part) "parts as top-level" $ headers =?>
+ , test (docbookTopLevelDiv TopLevelPart) "parts as top-level" $
+ headers =?>
unlines [ "<part>"
, " <title>header1</title>"
, " <chapter>"
@@ -279,6 +283,20 @@ tests = [ testGroup "line blocks"
, " </chapter>"
, "</part>"
]
+ , test (docbookTopLevelDiv TopLevelDefault) "default top-level" $
+ headers =?>
+ unlines [ "<sect1>"
+ , " <title>header1</title>"
+ , " <sect2>"
+ , " <title>header2</title>"
+ , " <sect3>"
+ , " <title>header3</title>"
+ , " <para>"
+ , " </para>"
+ , " </sect3>"
+ , " </sect2>"
+ , "</sect1>"
+ ]
]
]
]
diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs
index fb230e89a..d8bfa5924 100644
--- a/tests/Tests/Writers/LaTeX.hs
+++ b/tests/Tests/Writers/LaTeX.hs
@@ -88,45 +88,64 @@ tests = [ testGroup "code blocks"
<> header 2 (text "header2")
<> header 3 (text "header3")
- latexTopLevelDiv :: (ToPandoc a) => Division -> a -> String
+ latexTopLevelDiv :: (ToPandoc a) => TopLevelDivision -> a -> String
latexTopLevelDiv division =
- latexWithOpts def{ writerTopLevelDivision = Just division }
+ latexWithOpts def{ writerTopLevelDivision = division }
- beamerTopLevelDiv :: (ToPandoc a) => Division -> a -> String
+ beamerTopLevelDiv :: (ToPandoc a)
+ => TopLevelDivision -> a -> String
beamerTopLevelDiv division =
- latexWithOpts def { writerTopLevelDivision = Just division
+ latexWithOpts def { writerTopLevelDivision = division
, writerBeamer = True }
in
- [ test (latexTopLevelDiv Section) "sections as top-level" $ headers =?>
+ [ test (latexTopLevelDiv TopLevelSection)
+ "sections as top-level" $ headers =?>
unlines [ "\\section{header1}\n"
, "\\subsection{header2}\n"
, "\\subsubsection{header3}"
]
- , test (latexTopLevelDiv Chapter) "chapters as top-level" $ headers =?>
+ , test (latexTopLevelDiv TopLevelChapter)
+ "chapters as top-level" $ headers =?>
unlines [ "\\chapter{header1}\n"
, "\\section{header2}\n"
, "\\subsection{header3}"
]
- , test (latexTopLevelDiv Part) "parts as top-level" $ headers =?>
+ , test (latexTopLevelDiv TopLevelPart)
+ "parts as top-level" $ headers =?>
unlines [ "\\part{header1}\n"
, "\\chapter{header2}\n"
, "\\section{header3}"
]
- , test (beamerTopLevelDiv Section) "sections as top-level in beamer" $ headers =?>
+ , test (latexTopLevelDiv TopLevelDefault)
+ "default top-level" $ headers =?>
unlines [ "\\section{header1}\n"
, "\\subsection{header2}\n"
, "\\subsubsection{header3}"
]
- , test (beamerTopLevelDiv Chapter) "chapters are as part in beamer" $ headers =?>
+ , test (beamerTopLevelDiv TopLevelSection)
+ "sections as top-level in beamer" $ headers =?>
+ unlines [ "\\section{header1}\n"
+ , "\\subsection{header2}\n"
+ , "\\subsubsection{header3}"
+ ]
+ , test (beamerTopLevelDiv TopLevelChapter)
+ "chapters are as part in beamer" $ headers =?>
unlines [ "\\part{header1}\n"
, "\\section{header2}\n"
, "\\subsection{header3}"
]
- , test (beamerTopLevelDiv Part) "parts as top-level in beamer" $ headers =?>
+ , test (beamerTopLevelDiv TopLevelPart)
+ "parts as top-level in beamer" $ headers =?>
unlines [ "\\part{header1}\n"
, "\\section{header2}\n"
, "\\subsection{header3}"
]
+ , test (beamerTopLevelDiv TopLevelDefault)
+ "default top-level in beamer" $ headers =?>
+ unlines [ "\\section{header1}\n"
+ , "\\subsection{header2}\n"
+ , "\\subsubsection{header3}"
+ ]
]
]
]