{-# 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" $ "

\n @&\n

" =?> para (code "@&") , test jats "lang" $ "

\n @&\n

" =?> para (codeWith ("", ["c"], []) "@&") ] , testGroup "block code" [ test jats "basic" $ "@&" =?> codeBlock "@&" , test jats "lang" $ "@&" =?> codeBlockWith ("", ["c"], []) "@&" ] , testGroup "images" [ test jats "basic" $ "" =?> para (image "/url" "title" mempty) ] , test jats "bullet list" $ "\n\ \ \n\ \

\n\ \ first\n\ \

\n\ \
\n\ \ \n\ \

\n\ \ second\n\ \

\n\ \
\n\ \ \n\ \

\n\ \ third\n\ \

\n\ \
\n\ \
" =?> bulletList [ para $ text "first" , para $ text "second" , para $ text "third" ] , testGroup "definition lists" [ test jats "with internal link" $ "\n\ \ \n\ \ \n\ \ testing\n\ \ \n\ \ \n\ \

\n\ \ hi there\n\ \

\n\ \
\n\ \
\n\ \
" =?> definitionList [(link "#go" "" (str "testing"), [para (text "hi there")])] ] , testGroup "math" [ test jats "escape |" $ "

\n\ \ \n\ \ \n\ \ σ|{x}\n\ \

" =?> para (math "\\sigma|_{\\{x\\}}") , test jats "tex-math only" $ "

\n\ \ \n\ \ \n\ \

" =?> para (math "\\sigma|_{\\{x\\}}") , test jats "math ml only" $ "

\n\ \ \n\ \ σ|{x}\n\ \

" =?> para (math "\\sigma|_{\\{ x\\}}") ] , testGroup "headers" -- TODO fix footnotes in headers -- [ test jats "unnumbered header" $ -- "\n\ -- \ Header 1<fn>\n\ -- \ <p>\n\ -- \ note\n\ -- \ </p>\n\ -- \ </fn>\n\ -- \" -- =?> header 1 -- (text "Header 1" <> note (plain $ text "note")) [ test jats "unnumbered sub header" $ "\n\ \ Header\n\ \ \n\ \ Sub-Header\n\ \ \n\ \" =?> headerWith ("foo", [], []) 1 (text "Header") <> headerWith ("foo2", [], []) 2 (text "Sub-Header") , test jats "containing image" $ "\n\ \ <inline-graphic mimetype=\"image\" mime-subtype=\"jpeg\" xlink:href=\"imgs/foo.jpg\" />\n\ \" =?> header 1 (image "imgs/foo.jpg" "" mempty) ] ]