2017-12-24 22:48:18 +01:00
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2019-02-04 22:52:31 +01:00
|
|
|
|
{- |
|
|
|
|
|
Module : Tests.Readers.Org.Inline.Smart
|
2022-01-01 20:02:31 +01:00
|
|
|
|
Copyright : © 2014-2022 Albert Krewinkel
|
2019-02-04 22:52:31 +01:00
|
|
|
|
License : GNU GPL, version 2 or above
|
|
|
|
|
|
|
|
|
|
Maintainer : Albert Krewinkel <albert@zeitkraut.de>
|
|
|
|
|
Stability : alpha
|
|
|
|
|
Portability : portable
|
|
|
|
|
|
|
|
|
|
Test smart parsing of quotes, apostrophe, etc.
|
|
|
|
|
-}
|
2017-12-24 22:48:18 +01:00
|
|
|
|
module Tests.Readers.Org.Inline.Smart (tests) where
|
|
|
|
|
|
|
|
|
|
import Data.Text (Text)
|
|
|
|
|
import Test.Tasty (TestTree)
|
|
|
|
|
import Tests.Helpers ((=?>), purely, test)
|
2017-12-28 14:51:03 +01:00
|
|
|
|
import Text.Pandoc (ReaderOptions (readerExtensions),
|
2017-12-24 22:48:18 +01:00
|
|
|
|
Extension (Ext_smart), def, enableExtension,
|
|
|
|
|
getDefaultExtensions, readOrg)
|
|
|
|
|
import Text.Pandoc.Builder
|
|
|
|
|
|
|
|
|
|
orgSmart :: Text -> Pandoc
|
|
|
|
|
orgSmart = purely $
|
|
|
|
|
let extensionsSmart = enableExtension Ext_smart (getDefaultExtensions "org")
|
|
|
|
|
in readOrg def{ readerExtensions = extensionsSmart }
|
|
|
|
|
|
|
|
|
|
tests :: [TestTree]
|
|
|
|
|
tests =
|
|
|
|
|
[ test orgSmart "quote before ellipses"
|
|
|
|
|
("'...hi'"
|
|
|
|
|
=?> para (singleQuoted "…hi"))
|
|
|
|
|
|
|
|
|
|
, test orgSmart "apostrophe before emph"
|
|
|
|
|
("D'oh! A l'/aide/!"
|
|
|
|
|
=?> para ("D’oh! A l’" <> emph "aide" <> "!"))
|
|
|
|
|
|
|
|
|
|
, test orgSmart "apostrophe in French"
|
|
|
|
|
("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
|
|
|
|
|
=?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
|
|
|
|
|
|
|
|
|
|
, test orgSmart "Quotes cannot occur at the end of emphasized text"
|
|
|
|
|
("/say \"yes\"/" =?>
|
|
|
|
|
para ("/say" <> space <> doubleQuoted "yes" <> "/"))
|
|
|
|
|
|
|
|
|
|
, test orgSmart "Dashes are allowed at the borders of emphasis'"
|
|
|
|
|
("/foo---/" =?>
|
|
|
|
|
para (emph "foo—"))
|
|
|
|
|
|
|
|
|
|
, test orgSmart "Single quotes can be followed by emphasized text"
|
|
|
|
|
("Singles on the '/meat market/'" =?>
|
2018-01-19 21:25:24 -08:00
|
|
|
|
para ("Singles on the " <> singleQuoted (emph "meat market")))
|
2017-12-24 22:48:18 +01:00
|
|
|
|
|
|
|
|
|
, test orgSmart "Double quotes can be followed by emphasized text"
|
|
|
|
|
("Double income, no kids: \"/DINK/\"" =?>
|
2018-01-19 21:25:24 -08:00
|
|
|
|
para ("Double income, no kids: " <> doubleQuoted (emph "DINK")))
|
2017-12-24 22:48:18 +01:00
|
|
|
|
]
|