|
Packit Service |
d2f85f |
{-# LANGUAGE OverloadedStrings #-}
|
|
Packit Service |
d2f85f |
module Tests.Readers.JATS (tests) where
|
|
Packit Service |
d2f85f |
|
|
Packit Service |
d2f85f |
import Data.Text (Text)
|
|
Packit Service |
d2f85f |
import Test.Tasty
|
|
Packit Service |
d2f85f |
import Tests.Helpers
|
|
Packit Service |
d2f85f |
import Text.Pandoc
|
|
Packit Service |
d2f85f |
import Text.Pandoc.Arbitrary ()
|
|
Packit Service |
d2f85f |
import Text.Pandoc.Builder
|
|
Packit Service |
d2f85f |
|
|
Packit Service |
d2f85f |
jats :: Text -> Pandoc
|
|
Packit Service |
d2f85f |
jats = purely $ readJATS def
|
|
Packit Service |
d2f85f |
|
|
Packit Service |
d2f85f |
tests :: [TestTree]
|
|
Packit Service |
d2f85f |
tests = [ testGroup "inline code"
|
|
Packit Service |
d2f85f |
[ test jats "basic" $ "\n <monospace>@&</monospace>\n " =?> para (code "@&")
|
|
Packit Service |
d2f85f |
, test jats "lang" $ "\n @& \n " =?> para (codeWith ("", ["c"], []) "@&")
|
|
Packit Service |
d2f85f |
]
|
|
Packit Service |
d2f85f |
, testGroup "block code"
|
|
Packit Service |
d2f85f |
[ test jats "basic" $ "<preformat>@&</preformat>" =?> codeBlock "@&"
|
|
Packit Service |
d2f85f |
, test jats "lang" $ "@& " =?> codeBlockWith ("", ["c"], []) "@&"
|
|
Packit Service |
d2f85f |
]
|
|
Packit Service |
d2f85f |
, testGroup "images"
|
|
Packit Service |
d2f85f |
[ test jats "basic" $ "<graphic mimetype=\"image\" mime-subtype=\"\" xlink:href=\"/url\" xlink:title=\"title\" />"
|
|
Packit Service |
d2f85f |
=?> para (image "/url" "title" mempty)
|
|
Packit Service |
d2f85f |
]
|
|
Packit Service |
d2f85f |
, test jats "bullet list" $
|
|
Packit Service |
d2f85f |
"<list list-type=\"bullet\">\n\
|
|
Packit Service |
d2f85f |
\ <list-item>\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ first\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ </list-item>\n\
|
|
Packit Service |
d2f85f |
\ <list-item>\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ second\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ </list-item>\n\
|
|
Packit Service |
d2f85f |
\ <list-item>\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ third\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ </list-item>\n\
|
|
Packit Service |
d2f85f |
\</list>"
|
|
Packit Service |
d2f85f |
=?> bulletList [ para $ text "first"
|
|
Packit Service |
d2f85f |
, para $ text "second"
|
|
Packit Service |
d2f85f |
, para $ text "third"
|
|
Packit Service |
d2f85f |
]
|
|
Packit Service |
d2f85f |
, testGroup "definition lists"
|
|
Packit Service |
d2f85f |
[ test jats "with internal link" $
|
|
Packit Service |
d2f85f |
"<def-list>\n\
|
|
Packit Service |
d2f85f |
\ <def-item>\n\
|
|
Packit Service |
d2f85f |
\ <term>\n\
|
|
Packit Service |
d2f85f |
\ <xref alt=\"testing\" rid=\"go\">testing</xref>\n\
|
|
Packit Service |
d2f85f |
\ </term>\n\
|
|
Packit Service |
d2f85f |
\ <def>\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ hi there\n\
|
|
Packit Service |
d2f85f |
\ \n\
|
|
Packit Service |
d2f85f |
\ </def>\n\
|
|
Packit Service |
d2f85f |
\ </def-item>\n\
|
|
Packit Service |
d2f85f |
\</def-list>"
|
|
Packit Service |
d2f85f |
=?> definitionList [(link "#go" "" (str "testing"),
|
|
Packit Service |
d2f85f |
[para (text "hi there")])]
|
|
Packit Service |
d2f85f |
]
|
|
Packit Service |
d2f85f |
, testGroup "math"
|
|
Packit Service |
d2f85f |
[ test jats "escape |" $
|
|
Packit Service |
d2f85f |
"\n\
|
|
Packit Service |
d2f85f |
\ <inline-formula><alternatives>\n\
|
|
Packit Service |
d2f85f |
\ <tex-math></tex-math>\n\
|
|
Packit Service |
d2f85f |
\ <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\
|
|
Packit Service |
d2f85f |
\"
|
|
Packit Service |
d2f85f |
=?> para (math "\\sigma|_{\\{x\\}}")
|
|
Packit Service |
d2f85f |
, test jats "tex-math only" $
|
|
Packit Service |
d2f85f |
"\n\
|
|
Packit Service |
d2f85f |
\ <inline-formula><alternatives>\n\
|
|
Packit Service |
d2f85f |
\ <tex-math></tex-math>\n\
|
|
Packit Service |
d2f85f |
\"
|
|
Packit Service |
d2f85f |
=?> para (math "\\sigma|_{\\{x\\}}")
|
|
Packit Service |
d2f85f |
, test jats "math ml only" $
|
|
Packit Service |
d2f85f |
"\n\
|
|
Packit Service |
d2f85f |
\ <inline-formula><alternatives>\n\
|
|
Packit Service |
d2f85f |
\ <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\
|
|
Packit Service |
d2f85f |
\"
|
|
Packit Service |
d2f85f |
=?> para (math "\\sigma|_{\\{ x\\}}")
|
|
Packit Service |
d2f85f |
]
|
|
Packit Service |
d2f85f |
, testGroup "headers"
|
|
Packit Service |
d2f85f |
-- TODO fix footnotes in headers
|
|
Packit Service |
d2f85f |
-- [ test jats "unnumbered header" $
|
|
Packit Service |
d2f85f |
-- "<sec>\n\
|
|
Packit Service |
d2f85f |
-- \ <title>Header 1<fn>\n\
|
|
Packit Service |
d2f85f |
-- \ \n\
|
|
Packit Service |
d2f85f |
-- \ note\n\
|
|
Packit Service |
d2f85f |
-- \ \n\
|
|
Packit Service |
d2f85f |
-- \ </fn></title>\n\
|
|
Packit Service |
d2f85f |
-- \</sec>"
|
|
Packit Service |
d2f85f |
-- =?> header 1
|
|
Packit Service |
d2f85f |
-- (text "Header 1" <> note (plain $ text "note"))
|
|
Packit Service |
d2f85f |
[ test jats "unnumbered sub header" $
|
|
Packit Service |
d2f85f |
"<sec id=\"foo\">\n\
|
|
Packit Service |
d2f85f |
\ <title>Header</title>\n\
|
|
Packit Service |
d2f85f |
\ <sec id=\"foo2\">\n\
|
|
Packit Service |
d2f85f |
\ <title>Sub-Header</title>\n\
|
|
Packit Service |
d2f85f |
\ </sec>\n\
|
|
Packit Service |
d2f85f |
\</sec>"
|
|
Packit Service |
d2f85f |
=?> headerWith ("foo", [], []) 1
|
|
Packit Service |
d2f85f |
(text "Header")
|
|
Packit Service |
d2f85f |
<> headerWith ("foo2", [], []) 2
|
|
Packit Service |
d2f85f |
(text "Sub-Header")
|
|
Packit Service |
d2f85f |
, test jats "containing image" $
|
|
Packit Service |
d2f85f |
"<sec>\n\
|
|
Packit Service |
d2f85f |
\ <title><inline-graphic mimetype=\"image\" mime-subtype=\"jpeg\" xlink:href=\"imgs/foo.jpg\" /></title>\n\
|
|
Packit Service |
d2f85f |
\</sec>"
|
|
Packit Service |
d2f85f |
=?> header 1 (image "imgs/foo.jpg" "" mempty)
|
|
Packit Service |
d2f85f |
]
|
|
Packit Service |
d2f85f |
]
|