2013-05-11 07:53:35 +02:00
{- # LANGUAGE OverloadedStrings, ScopedTypeVariables # -}
2011-01-26 18:10:39 +01:00
module Tests.Readers.RST ( tests ) where
import Text.Pandoc.Definition
import Test.Framework
import Tests.Helpers
import Tests.Arbitrary ()
import Text.Pandoc.Builder
import Text.Pandoc
2013-05-11 07:53:35 +02:00
import Data.Monoid ( mempty )
2011-01-26 18:10:39 +01:00
rst :: String -> Pandoc
2013-05-11 07:53:35 +02:00
rst = readRST def { readerStandalone = True }
2011-01-26 18:10:39 +01:00
2012-02-05 22:23:06 +01:00
infix 4 =:
2011-01-26 18:10:39 +01:00
( =: ) :: ToString c
=> String -> ( String , c ) -> Test
( =: ) = test rst
tests :: [ Test ]
2011-04-11 23:45:42 +02:00
tests = [ " line block with blank line " =:
2013-01-13 20:14:50 +01:00
" | a \ n | \ n | b " =?> para ( str " a " ) <>
para ( str " \ 160 b " )
2013-01-23 17:47:43 +01:00
, " field list " =: unlines
2013-05-11 07:53:35 +02:00
[ " para "
, " "
, " :Hostname: media08 "
2013-01-23 17:47:43 +01:00
, " :IP address: 10.0.0.19 "
, " :Size: 3ru "
, " :Version: 1 "
, " :Indentation: Since the field marker may be quite long, the second "
, " and subsequent lines of the field body do not have to line up "
, " with the first line, but they must be indented relative to the "
, " field name marker, and they must line up with each other. "
, " :Parameter i: integer "
, " :Final: item "
, " on two lines " ]
2013-05-11 07:53:35 +02:00
=?> ( doc
$ para " para " <>
definitionList [ ( str " Hostname " , [ para " media08 " ] )
2011-01-27 02:18:02 +01:00
, ( str " IP address " , [ para " 10.0.0.19 " ] )
, ( str " Size " , [ para " 3ru " ] )
, ( str " Version " , [ para " 1 " ] )
, ( str " Indentation " , [ para " Since the field marker may be quite long, the second and subsequent lines of the field body do not have to line up with the first line, but they must be indented relative to the field name marker, and they must line up with each other. " ] )
, ( str " Parameter i " , [ para " integer " ] )
2011-03-13 02:08:23 +01:00
, ( str " Final " , [ para " item on two lines " ] )
2011-01-26 18:10:39 +01:00
] )
2013-05-11 07:53:35 +02:00
, " initial field list " =: unlines
[ " ===== "
, " Title "
, " ===== "
, " -------- "
, " Subtitle "
, " -------- "
, " "
, " :Version: 1 "
]
=?> ( setMeta " version " ( para " 1 " )
$ setMeta " title " ( " Title " :: Inlines )
$ setMeta " subtitle " ( " Subtitle " :: Inlines )
$ doc mempty )
2011-03-18 19:27:42 +01:00
, " URLs with following punctuation " =:
( " http://google.com, http://yahoo.com; http://foo.bar.baz. \ n " ++
" http://foo.bar/baz_(bam) (http://foo.bar) " ) =?>
2011-12-13 23:29:07 +01:00
para ( link " http://google.com " " " " http://google.com " <> " , " <>
link " http://yahoo.com " " " " http://yahoo.com " <> " ; " <>
link " http://foo.bar.baz " " " " http://foo.bar.baz " <> " . " <>
2011-03-18 19:27:42 +01:00
link " http://foo.bar/baz_(bam) " " " " http://foo.bar/baz_(bam) "
2011-12-13 23:29:07 +01:00
<> " ( " <> link " http://foo.bar " " " " http://foo.bar " <> " ) " )
2011-01-26 18:10:39 +01:00
]