diff options
| author | Hamish Mackenzie <Hamish.K.Mackenzie@googlemail.com> | 2017-12-20 13:54:02 +1300 |
|---|---|---|
| committer | Hamish Mackenzie <Hamish.K.Mackenzie@googlemail.com> | 2017-12-20 13:54:02 +1300 |
| commit | 5d3c9e56460165be452b672f12fc476e7a5ed3a9 (patch) | |
| tree | 03c924628d4ba99ab4531db86364ab7576add007 /test/Tests | |
| parent | 1e21cfb251506d42cbdcf3e24661f08633817572 (diff) | |
| download | pandoc-5d3c9e56460165be452b672f12fc476e7a5ed3a9.tar.gz | |
Add Basic JATS reader based on DocBook reader
Diffstat (limited to 'test/Tests')
| -rw-r--r-- | test/Tests/Old.hs | 2 | ||||
| -rw-r--r-- | test/Tests/Readers/JATS.hs | 111 |
2 files changed, 113 insertions, 0 deletions
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index 9c6b9f660..bbd51ee98 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -79,6 +79,8 @@ tests = [ testGroup "markdown" ] , testGroup "jats" [ testGroup "writer" $ writerTests "jats" + , test "reader" ["-r", "jats", "-w", "native", "-s"] + "jats-reader.xml" "jats-reader.native" ] , testGroup "native" [ testGroup "writer" $ writerTests "native" diff --git a/test/Tests/Readers/JATS.hs b/test/Tests/Readers/JATS.hs new file mode 100644 index 000000000..ed6317c71 --- /dev/null +++ b/test/Tests/Readers/JATS.hs @@ -0,0 +1,111 @@ +{-# LANGUAGE OverloadedStrings #-} +module Tests.Readers.JATS (tests) where + +import Data.Text (Text) +import Test.Tasty +import Tests.Helpers +import Text.Pandoc +import Text.Pandoc.Arbitrary () +import Text.Pandoc.Builder + +jats :: Text -> Pandoc +jats = purely $ readJATS def + +tests :: [TestTree] +tests = [ testGroup "inline code" + [ test jats "basic" $ "<p>\n <monospace>@&</monospace>\n</p>" =?> para (code "@&") + ] + , testGroup "images" + [ test jats "basic" $ "<graphic mimetype=\"image\" mime-subtype=\"\" xlink:href=\"/url\" xlink:title=\"title\" />" + =?> para (image "/url" "title" mempty) + ] + , test jats "bullet list" $ + "<list list-type=\"bullet\">\n\ + \ <list-item>\n\ + \ <p>\n\ + \ first\n\ + \ </p>\n\ + \ </list-item>\n\ + \ <list-item>\n\ + \ <p>\n\ + \ second\n\ + \ </p>\n\ + \ </list-item>\n\ + \ <list-item>\n\ + \ <p>\n\ + \ third\n\ + \ </p>\n\ + \ </list-item>\n\ + \</list>" + =?> bulletList [ para $ text "first" + , para $ text "second" + , para $ text "third" + ] + , testGroup "definition lists" + [ test jats "with internal link" $ + "<def-list>\n\ + \ <def-item>\n\ + \ <term>\n\ + \ <xref alt=\"testing\" rid=\"go\">testing</xref>\n\ + \ </term>\n\ + \ <def>\n\ + \ <p>\n\ + \ hi there\n\ + \ </p>\n\ + \ </def>\n\ + \ </def-item>\n\ + \</def-list>" + =?> definitionList [(link "#go" "" (str "testing"), + [para (text "hi there")])] + ] + , testGroup "math" + [ test jats "escape |" $ + "<p>\n\ + \ <inline-formula><alternatives>\n\ + \ <tex-math><![CDATA[\\sigma|_{\\{x\\}}]]></tex-math>\n\ + \ <mml:math display=\"inline\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\"><mml:mrow><mml:mi>σ</mml:mi><mml:msub><mml:mo stretchy=\"false\" form=\"prefix\">|</mml:mo><mml:mrow><mml:mo stretchy=\"false\" form=\"prefix\">{</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy=\"false\" form=\"postfix\">}</mml:mo></mml:mrow></mml:msub></mml:mrow></mml:math></alternatives></inline-formula>\n\ + \</p>" + =?> para (math "\\sigma|_{\\{x\\}}") + , test jats "tex-math only" $ + "<p>\n\ + \ <inline-formula><alternatives>\n\ + \ <tex-math><![CDATA[\\sigma|_{\\{x\\}}]]></tex-math>\n\ + \</p>" + =?> para (math "\\sigma|_{\\{x\\}}") + , test jats "math ml only" $ + "<p>\n\ + \ <inline-formula><alternatives>\n\ + \ <mml:math display=\"inline\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\"><mml:mrow><mml:mi>σ</mml:mi><mml:msub><mml:mo stretchy=\"false\" form=\"prefix\">|</mml:mo><mml:mrow><mml:mo stretchy=\"false\" form=\"prefix\">{</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy=\"false\" form=\"postfix\">}</mml:mo></mml:mrow></mml:msub></mml:mrow></mml:math></alternatives></inline-formula>\n\ + \</p>" + =?> para (math "\\sigma|_{\\{ x\\}}") + ] + , testGroup "headers" +-- TODO fix footnotes in headers +-- [ test jats "unnumbered header" $ +-- "<sec>\n\ +-- \ <title>Header 1<fn>\n\ +-- \ <p>\n\ +-- \ note\n\ +-- \ </p>\n\ +-- \ </fn></title>\n\ +-- \</sec>" +-- =?> header 1 +-- (text "Header 1" <> note (plain $ text "note")) + [ test jats "unnumbered sub header" $ + "<sec id=\"foo\">\n\ + \ <title>Header</title>\n\ + \ <sec id=\"foo2\">\n\ + \ <title>Sub-Header</title>\n\ + \ </sec>\n\ + \</sec>" + =?> headerWith ("foo", [], []) 1 + (text "Header") + <> headerWith ("foo2", [], []) 2 + (text "Sub-Header") + , test jats "containing image" $ + "<sec>\n\ + \ <title><inline-graphic mimetype=\"image\" mime-subtype=\"jpeg\" xlink:href=\"imgs/foo.jpg\" /></title>\n\ + \</sec>" + =?> header 1 (image "imgs/foo.jpg" "" mempty) + ] + ] |
