{-# LANGUAGE OverloadedStrings #-}
module Tests.Readers.Muse (tests) where
import Data.List (intersperse)
import Data.Text (Text)
import qualified Data.Text as T
import Test.Tasty
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
import Text.Pandoc.Class
muse :: Text -> Pandoc
muse = purely $ \s -> do
putCommonState
def { stInputFiles = Just ["in"]
, stOutputFile = Just "out"
}
readMuse def s
infix 4 =:
(=:) :: ToString c
=> String -> (Text, c) -> TestTree
(=:) = test muse
spcSep :: [Inlines] -> Inlines
spcSep = mconcat . intersperse space
tests :: [TestTree]
tests =
[ testGroup "Inlines"
[ "Plain String" =:
"Hello, World" =?>
para (spcSep [ "Hello,", "World" ])
, "Emphasis" =: "*Foo bar*" =?> para (emph . spcSep $ ["Foo", "bar"])
, "Emphasis tag" =: "Foo bar" =?> para (emph . spcSep $ ["Foo", "bar"])
, "Strong" =:
"**Cider**" =?>
para (strong "Cider")
, "Strong tag" =: "Strong" =?> para (strong "Strong")
, "Strong Emphasis" =:
"***strength***" =?>
para (strong . emph $ "strength")
, "Superscript tag" =: "Superscript" =?> para (superscript "Superscript")
, "Subscript tag" =: "Subscript" =?> para (subscript "Subscript")
, "Strikeout tag" =: "Strikeout" =?> para (strikeout "Strikeout")
, "Linebreak" =: "Line
break" =?> para ("Line" <> linebreak <> "break")
, "Code" =: "=foo(bar)=" =?> para (code "foo(bar)")
, "Code tag" =: "foo(bar)
" =?> para (code "foo(bar)")
, testGroup "Links"
[ "Link without description" =:
"[[https://amusewiki.org/]]" =?>
para (link "https://amusewiki.org/" "" (str "https://amusewiki.org/"))
, "Link with description" =:
"[[https://amusewiki.org/][A Muse Wiki]]" =?>
para (link "https://amusewiki.org/" "" (text "A Muse Wiki"))
, "Image" =:
"[[image.jpg]]" =?>
para (image "image.jpg" "" mempty)
, "Image with description" =:
"[[image.jpg][Image]]" =?>
para (image "image.jpg" "" (text "Image"))
, "Image link" =:
"[[URL:image.jpg]]" =?>
para (link "image.jpg" "" (str "image.jpg"))
, "Image link with description" =:
"[[URL:image.jpg][Image]]" =?>
para (link "image.jpg" "" (text "Image"))
]
]
, testGroup "Blocks"
[ "Quote" =: "Hello, world
" =?> blockQuote (para $ text "Hello, world")
, "Center" =: "