diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2021-12-29 15:00:59 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2021-12-29 15:00:59 +0200 |
commit | b4361712899fd0183fea5513180cb383979616de (patch) | |
tree | 688ab7ee2ab3a8cd32b4e37b506099aec95388f7 /test/Tests/Readers | |
parent | 726ad97faebe59e024d68d293e663c02bbe423c8 (diff) | |
parent | d960282b105a6469c760b4308a3b81da723b7256 (diff) | |
download | pandoc-b4361712899fd0183fea5513180cb383979616de.tar.gz |
Merge https://github.com/jgm/pandoc
Diffstat (limited to 'test/Tests/Readers')
-rw-r--r-- | test/Tests/Readers/Docx.hs | 16 | ||||
-rw-r--r-- | test/Tests/Readers/FB2.hs | 2 | ||||
-rw-r--r-- | test/Tests/Readers/Markdown.hs | 48 | ||||
-rw-r--r-- | test/Tests/Readers/Org/Inline/Citation.hs | 87 | ||||
-rw-r--r-- | test/Tests/Readers/Org/Meta.hs | 2 | ||||
-rw-r--r-- | test/Tests/Readers/RST.hs | 9 | ||||
-rw-r--r-- | test/Tests/Readers/RTF.hs | 42 |
7 files changed, 152 insertions, 54 deletions
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index 220c7d9c5..be5b89b88 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -148,6 +148,18 @@ tests = [ testGroup "document" "docx/instrText_hyperlink.docx" "docx/instrText_hyperlink.native" , testCompare + "nested fields with <w:instrText> tag" + "docx/nested_instrText.docx" + "docx/nested_instrText.native" + , testCompare + "empty fields with <w:instrText> tag" + "docx/empty_field.docx" + "docx/empty_field.native" + , testCompare + "pageref hyperlinks in <w:instrText> tag" + "docx/pageref.docx" + "docx/pageref.native" + , testCompare "inline image" "docx/image.docx" "docx/image_no_embed.native" @@ -306,6 +318,10 @@ tests = [ testGroup "document" "docx/block_quotes.docx" "docx/block_quotes_parse_indent.native" , testCompare + "blockquotes (parsing indent relative to the indent of the parent style as blockquote)" + "docx/relative_indentation_blockquotes.docx" + "docx/relative_indentation_blockquotes.native" + , testCompare "hanging indents" "docx/hanging_indent.docx" "docx/hanging_indent.native" diff --git a/test/Tests/Readers/FB2.hs b/test/Tests/Readers/FB2.hs index 42054a235..d540f8b6a 100644 --- a/test/Tests/Readers/FB2.hs +++ b/test/Tests/Readers/FB2.hs @@ -7,7 +7,7 @@ Stability : alpha Portability : portable -Tests for the EPUB mediabag. +Tests for the FB2 reader. -} module Tests.Readers.FB2 (tests) where diff --git a/test/Tests/Readers/Markdown.hs b/test/Tests/Readers/Markdown.hs index f055ab197..02fc0d8ce 100644 --- a/test/Tests/Readers/Markdown.hs +++ b/test/Tests/Readers/Markdown.hs @@ -36,6 +36,9 @@ markdownGH :: Text -> Pandoc markdownGH = purely $ readMarkdown def { readerExtensions = githubMarkdownExtensions } +markdownMMD :: Text -> Pandoc +markdownMMD = purely $ readMarkdown def { + readerExtensions = multimarkdownExtensions } infix 4 =: (=:) :: ToString c => String -> (Text, c) -> TestTree @@ -360,6 +363,51 @@ tests = [ testGroup "inline code" ("**this should \"be bold**" =?> para (strong "this should \8220be bold")) ] + , testGroup "sub- and superscripts" + [ + test markdownMMD "normal subscript" + ("H~2~" + =?> para ("H" <> subscript "2")) + , test markdownMMD "normal superscript" + ("x^3^" + =?> para ("x" <> superscript "3")) + , test markdownMMD "short subscript delimeted by space" + ("O~2 is dangerous" + =?> para ("O" <> subscript "2" <> space <> "is dangerous")) + , test markdownMMD "short subscript delimeted by newline" + ("O~2\n" + =?> para ("O" <> subscript "2")) + , test markdownMMD "short subscript delimeted by EOF" + ("O~2" + =?> para ("O" <> subscript "2")) + , test markdownMMD "short subscript delimited by punctuation" + ("O~2." + =?> para ("O" <> subscript "2" <> ".")) + , test markdownMMD "short subscript delimited by emph" + ("O~2*combustible!*" + =?> para ("O" <> subscript "2" <> emph "combustible!")) + , test markdownMMD "no nesting in short subscripts" + ("y~*2*" + =?> para ("y~" <> emph "2")) + , test markdownMMD "short superscript delimeted by space" + ("x^2 = y" + =?> para ("x" <> superscript "2" <> space <> "= y")) + , test markdownMMD "short superscript delimeted by newline" + ("x^2\n" + =?> para ("x" <> superscript "2")) + , test markdownMMD "short superscript delimeted by ExF" + ("x^2" + =?> para ("x" <> superscript "2")) + , test markdownMMD "short superscript delimited by punctuation" + ("x^2." + =?> para ("x" <> superscript "2" <> ".")) + , test markdownMMD "short superscript delimited by emph" + ("x^2*combustible!*" + =?> para ("x" <> superscript "2" <> emph "combustible!")) + , test markdownMMD "no nesting in short superscripts" + ("y^*2*" + =?> para ("y^" <> emph "2")) + ] , testGroup "footnotes" [ "indent followed by newline and flush-left text" =: "[^1]\n\n[^1]: my note\n\n \nnot in note\n" diff --git a/test/Tests/Readers/Org/Inline/Citation.hs b/test/Tests/Readers/Org/Inline/Citation.hs index a11804983..2d0d460a2 100644 --- a/test/Tests/Readers/Org/Inline/Citation.hs +++ b/test/Tests/Readers/Org/Inline/Citation.hs @@ -19,9 +19,9 @@ import Text.Pandoc.Builder tests :: [TestTree] tests = - [ testGroup "Markdown-style citations" + [ testGroup "Org-cite citations" [ "Citation" =: - "[@nonexistent]" =?> + "[cite:@nonexistent]" =?> let citation = Citation { citationId = "nonexistent" , citationPrefix = [] @@ -29,10 +29,10 @@ tests = , citationMode = NormalCitation , citationNoteNum = 0 , citationHash = 0} - in (para $ cite [citation] "[@nonexistent]") + in (para $ cite [citation] "[cite:@nonexistent]") , "Citation containing text" =: - "[see @item1 p. 34-35]" =?> + "[cite:see @item1 p. 34-35]" =?> let citation = Citation { citationId = "item1" , citationPrefix = [Str "see"] @@ -40,7 +40,37 @@ tests = , citationMode = NormalCitation , citationNoteNum = 0 , citationHash = 0} - in (para $ cite [citation] "[see @item1 p. 34-35]") + in (para $ cite [citation] "[cite:see @item1 p. 34-35]") + + , "Author-in-text citation with locator and suffix" =: + "[cite/t:see @item1 p. 34-35 and *passim*; @item2]" =?> + let citations = + [ Citation + { citationId = "item1" + , citationPrefix = [ Str "see" ] + , citationSuffix = + [ Str "p." + , Space + , Str "34-35" + , Space + , Str "and" + , Space + , Strong [ Str "passim" ] + ] + , citationMode = AuthorInText + , citationNoteNum = 0 + , citationHash = 0 + } + , Citation + { citationId = "item2" + , citationPrefix = [] + , citationSuffix = [] + , citationMode = NormalCitation + , citationNoteNum = 0 + , citationHash = 0 + } + ] + in (para $ cite citations "[cite/t:see @item1 p. 34-35 and *passim*; @item2]") ] , testGroup "org-ref citations" @@ -169,53 +199,6 @@ tests = in (para $ cite [citation] "[[citep:Dominik201408][See page 20::, for example]]") ] - , testGroup "Berkeley-style citations" $ - let pandocCite = Citation - { citationId = "Pandoc" - , citationPrefix = mempty - , citationSuffix = mempty - , citationMode = NormalCitation - , citationNoteNum = 0 - , citationHash = 0 - } - pandocInText = pandocCite { citationMode = AuthorInText } - dominikCite = Citation - { citationId = "Dominik201408" - , citationPrefix = mempty - , citationSuffix = mempty - , citationMode = NormalCitation - , citationNoteNum = 0 - , citationHash = 0 - } - dominikInText = dominikCite { citationMode = AuthorInText } - in - [ "Berkeley-style in-text citation" =: - "See @Dominik201408." =?> - para ("See " - <> cite [dominikInText] "@Dominik201408" - <> ".") - - , "Berkeley-style parenthetical citation list" =: - "[(cite): see; @Dominik201408;also @Pandoc; and others]" =?> - let pandocCite' = pandocCite { - citationPrefix = toList "also" - , citationSuffix = toList "and others" - } - dominikCite' = dominikCite { - citationPrefix = toList "see" - } - in (para $ cite [dominikCite', pandocCite'] "") - - , "Berkeley-style plain citation list" =: - "[cite: See; @Dominik201408; and @Pandoc; and others]" =?> - let pandocCite' = pandocInText { citationPrefix = toList "and" } - in (para $ "See " - <> cite [dominikInText] "" - <> "," <> space - <> cite [pandocCite'] "" - <> "," <> space <> "and others") - ] - , "LaTeX citation" =: "\\cite{Coffee}" =?> let citation = Citation diff --git a/test/Tests/Readers/Org/Meta.hs b/test/Tests/Readers/Org/Meta.hs index 6363d84b0..41a41cb00 100644 --- a/test/Tests/Readers/Org/Meta.hs +++ b/test/Tests/Readers/Org/Meta.hs @@ -238,7 +238,7 @@ tests = , " :setting: foo" , " :END:" ] =?> - (mempty::Blocks) + (setMeta "setting" ("foo" :: T.Text) (doc mempty)) , "Logbook drawer" =: T.unlines [ " :LogBook:" diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs index a12b59fc2..e9ab8cc11 100644 --- a/test/Tests/Readers/RST.hs +++ b/test/Tests/Readers/RST.hs @@ -179,6 +179,15 @@ tests = [ "line block with blank line" =: , "custom code role with language field" =: ".. role:: lhs(code)\n :language: haskell\n\n:lhs:`a`" =?> para (codeWith ("", ["lhs", "haskell"], []) "a") + , "custom role with class field" + =: ".. role:: classy\n :class: myclass\n\n:classy:`a`" + =?> para (spanWith ("", ["myclass"], []) "a") + , "custom role with class field containing multiple whitespace-separated classes" + =: ".. role:: classy\n :class: myclass1 myclass2\n myclass3\n\n:classy:`a`" + =?> para (spanWith ("", ["myclass1", "myclass2", "myclass3"], []) "a") + , "custom role with inherited class field" + =: ".. role:: classy\n :class: myclass1\n.. role:: classier(classy)\n :class: myclass2\n\n:classier:`a`" + =?> para (spanWith ("", ["myclass2", "myclass1"], []) "a") , "custom role with unspecified parent role" =: ".. role:: classy\n\n:classy:`text`" =?> para (spanWith ("", ["classy"], []) "text") diff --git a/test/Tests/Readers/RTF.hs b/test/Tests/Readers/RTF.hs new file mode 100644 index 000000000..1b335274b --- /dev/null +++ b/test/Tests/Readers/RTF.hs @@ -0,0 +1,42 @@ +{- | + Module : Tests.Readers.RTF + Copyright : © 2021 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : jgm@berkeley.edu + Stability : alpha + Portability : portable + +Tests for the RTF reader. +-} +module Tests.Readers.RTF (tests) where + +import Test.Tasty +import Tests.Helpers +import Text.Pandoc +import System.FilePath (replaceExtension, (</>), (<.>)) + +rtfTest :: TestName -> TestTree +rtfTest name = testGolden name native path + (\t -> runIOorExplode + (readRTF def t >>= + writeNative def{ writerTemplate = Just mempty })) + where native = replaceExtension path ".native" + path = "rtf" </> name <.> "rtf" + + +tests :: [TestTree] +tests = map rtfTest [ "footnote" + , "accent" + , "unicode" + , "image" + , "link" + , "heading" + , "formatting" + , "list_simple" + , "list_complex" + , "bookmark" + , "table_simple" + , "table_error_codes" + ] + |