2018-03-18 10:46:28 -07:00
|
|
|
{-# LANGUAGE NoImplicitPrelude #-}
|
2017-12-24 22:48:18 +01:00
|
|
|
module Tests.Readers.Org.Shared
|
|
|
|
( (=:)
|
|
|
|
, org
|
|
|
|
, spcSep
|
|
|
|
, tagSpan
|
|
|
|
) where
|
|
|
|
|
2018-03-18 10:46:28 -07:00
|
|
|
import Prelude
|
2017-12-24 22:48:18 +01:00
|
|
|
import Data.List (intersperse)
|
|
|
|
import Data.Text (Text)
|
|
|
|
import Tests.Helpers (ToString, purely, test)
|
|
|
|
import Test.Tasty (TestTree)
|
|
|
|
import Text.Pandoc (Pandoc, ReaderOptions (readerExtensions),
|
|
|
|
def, getDefaultExtensions, readOrg)
|
|
|
|
import Text.Pandoc.Builder (Inlines, smallcaps, space, spanWith, str)
|
|
|
|
|
|
|
|
org :: Text -> Pandoc
|
|
|
|
org = purely $ readOrg def{ readerExtensions = getDefaultExtensions "org" }
|
|
|
|
|
|
|
|
infix 4 =:
|
|
|
|
(=:) :: ToString c
|
|
|
|
=> String -> (Text, c) -> TestTree
|
|
|
|
(=:) = test org
|
|
|
|
|
|
|
|
spcSep :: [Inlines] -> Inlines
|
|
|
|
spcSep = mconcat . intersperse space
|
|
|
|
|
|
|
|
-- | Create a span for the given tag.
|
|
|
|
tagSpan :: String -> Inlines
|
|
|
|
tagSpan t = spanWith ("", ["tag"], [("tag-name", t)]) . smallcaps $ str t
|