diff options
Diffstat (limited to 'tests/Tests')
-rw-r--r-- | tests/Tests/Readers/Docx.hs | 8 | ||||
-rw-r--r-- | tests/Tests/Readers/EPUB.hs | 5 | ||||
-rw-r--r-- | tests/Tests/Readers/Markdown.hs | 4 | ||||
-rw-r--r-- | tests/Tests/Readers/Org.hs | 10 | ||||
-rw-r--r-- | tests/Tests/Shared.hs | 37 | ||||
-rw-r--r-- | tests/Tests/Writers/LaTeX.hs | 10 |
6 files changed, 50 insertions, 24 deletions
diff --git a/tests/Tests/Readers/Docx.hs b/tests/Tests/Readers/Docx.hs index 234b1b5b7..565d117e9 100644 --- a/tests/Tests/Readers/Docx.hs +++ b/tests/Tests/Readers/Docx.hs @@ -153,6 +153,14 @@ tests = [ testGroup "inlines" "docx/already_auto_ident.docx" "docx/already_auto_ident.native" , testCompare + "numbered headers automatically made into list" + "docx/numbered_header.docx" + "docx/numbered_header.native" + , testCompare + "headers in other languages" + "docx/danish_headers.docx" + "docx/danish_headers.native" + , testCompare "lists" "docx/lists.docx" "docx/lists.native" diff --git a/tests/Tests/Readers/EPUB.hs b/tests/Tests/Readers/EPUB.hs index f27ea979f..0d19a8400 100644 --- a/tests/Tests/Readers/EPUB.hs +++ b/tests/Tests/Readers/EPUB.hs @@ -8,6 +8,7 @@ import qualified Data.ByteString.Lazy as BL import Text.Pandoc.Readers.EPUB import Text.Pandoc.MediaBag (MediaBag, mediaDirectory) import Control.Applicative +import System.FilePath (joinPath) getMediaBag :: FilePath -> IO MediaBag getMediaBag fp = snd . readEPUB def <$> BL.readFile fp @@ -22,12 +23,12 @@ testMediaBag fp bag = do (actBag == bag) featuresBag :: [(String, String, Int)] -featuresBag = [("img/ElementaryMathExample.png","image/png",1331),("img/Maghreb1.png","image/png",2520),("img/check.gif","image/gif",1340),("img/check.jpg","image/jpeg",2661),("img/check.png","image/png",2815),("img/cichons_diagram.png","image/png",7045),("img/complex_number.png","image/png",5238),("img/multiscripts_and_greek_alphabet.png","image/png",10060)] +featuresBag = [(joinPath ["img","check.gif"],"image/gif",1340),(joinPath ["img","check.jpg"],"image/jpeg",2661),(joinPath ["img","check.png"],"image/png",2815),(joinPath ["img","multiscripts_and_greek_alphabet.png"],"image/png",10060)] tests :: [Test] tests = [ testGroup "EPUB Mediabag" [ testCase "features bag" - (testMediaBag "epub/features.epub" featuresBag) + (testMediaBag "epub/img.epub" featuresBag) ] ] diff --git a/tests/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs index 6e64a6f15..b45d94032 100644 --- a/tests/Tests/Readers/Markdown.hs +++ b/tests/Tests/Readers/Markdown.hs @@ -266,10 +266,10 @@ tests = [ testGroup "inline code" , testGroup "lists" [ "issue #1154" =: " - <div>\n first div breaks\n </div>\n\n <button>if this button exists</button>\n\n <div>\n with this div too.\n </div>\n" - =?> bulletList [divWith nullAttr (plain $ text "first div breaks") <> + =?> bulletList [divWith nullAttr (para $ text "first div breaks") <> rawBlock "html" "<button>" <> plain (text "if this button exists") <> rawBlock "html" "</button>" <> - divWith nullAttr (plain $ text "with this div too.")] + divWith nullAttr (para $ text "with this div too.")] ] ] diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs index cc4e495f3..92ec8155b 100644 --- a/tests/Tests/Readers/Org.hs +++ b/tests/Tests/Readers/Org.hs @@ -126,6 +126,10 @@ tests = , (emph "b") <> "." ]) + , "Markup should work properly after a blank line" =: + unlines ["foo", "", "/bar/"] =?> + (para $ text "foo") <> (para $ emph $ text "bar") + , "Inline math must stay within three lines" =: unlines [ "$a", "b", "c$", "$d", "e", "f", "g$" ] =?> para ((math "a\nb\nc") <> space <> @@ -698,7 +702,9 @@ tests = ] ]) ] - + , "Definition list with multi-word term" =: + " - Elijah Wood :: He plays Frodo" =?> + definitionList [ ("Elijah" <> space <> "Wood", [plain $ "He" <> space <> "plays" <> space <> "Frodo"])] , "Compact definition list" =: unlines [ "- ATP :: adenosine 5' triphosphate" , "- DNA :: deoxyribonucleic acid" @@ -944,7 +950,7 @@ tests = , "" , "#+RESULTS:" , ": 65" ] =?> - rawBlock "html" "" + rawBlock "html" "" , "Example block" =: unlines [ "#+begin_example" diff --git a/tests/Tests/Shared.hs b/tests/Tests/Shared.hs index b6671835c..9b55b7b1d 100644 --- a/tests/Tests/Shared.hs +++ b/tests/Tests/Shared.hs @@ -9,6 +9,7 @@ import Test.Framework.Providers.HUnit import Test.HUnit ( assertBool, (@?=) ) import Text.Pandoc.Builder import Data.Monoid +import System.FilePath (joinPath) tests :: [Test] tests = [ testGroup "normalize" @@ -40,21 +41,21 @@ p_normalize_no_trailing_spaces ils = null ils' || last ils' /= Space testCollapse :: [Test] testCollapse = map (testCase "collapse") - [ (collapseFilePath "" @?= "") - , (collapseFilePath "./foo" @?= "foo") - , (collapseFilePath "././../foo" @?= "../foo") - , (collapseFilePath "../foo" @?= "../foo") - , (collapseFilePath "/bar/../baz" @?= "/baz") - , (collapseFilePath "/../baz" @?= "/../baz") - , (collapseFilePath "./foo/.././bar/../././baz" @?= "baz") - , (collapseFilePath "./" @?= "") - , (collapseFilePath "././" @?= "") - , (collapseFilePath "../" @?= "..") - , (collapseFilePath ".././" @?= "..") - , (collapseFilePath "./../" @?= "..") - , (collapseFilePath "../../" @?= "../..") - , (collapseFilePath "parent/foo/baz/../bar" @?= "parent/foo/bar") - , (collapseFilePath "parent/foo/baz/../../bar" @?= "parent/bar") - , (collapseFilePath "parent/foo/.." @?= "parent") - , (collapseFilePath "/parent/foo/../../bar" @?= "/bar") - , (collapseFilePath "/./parent/foo" @?= "/parent/foo")] + [ (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""])) + , (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"])) + , (collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]])) + , (collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"])) + , (collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"])) + , (collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"])) + , (collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"])) + , (collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""])) + , (collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""])) + , (collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."])) + , (collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."])) + , (collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."])) + , (collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."])) + , (collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"])) + , (collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"])) + , (collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"])) + , (collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"])) + , (collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"]))] diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs index 8ce73c099..4d2d3fc05 100644 --- a/tests/Tests/Writers/LaTeX.hs +++ b/tests/Tests/Writers/LaTeX.hs @@ -53,6 +53,16 @@ tests = [ testGroup "code blocks" headerWith ("foo",["unnumbered"],[]) 1 (text "Header 1" <> note (plain $ text "note")) =?> "\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n" + , "in list item" =: + bulletList [header 2 (text "foo")] =?> + "\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}" + , "in definition list item" =: + definitionList [(text "foo", [header 2 (text "bar"), + para $ text "baz"])] =?> + "\\begin{description}\n\\item[foo] ~ \n\\subsection{bar}\n\nbaz\n\\end{description}" + , "containing image" =: + header 1 (image "imgs/foo.jpg" "" (text "Alt text")) =?> + "\\section{\\protect\\includegraphics{imgs/foo.jpg}}" ] , testGroup "inline code" [ "struck out and highlighted" =: |