"Fossies" - the Fresh Open Source Software Archive

Member "pandoc-2.7.3/test/Tests/Readers/Org/Inline/Smart.hs" (12 Jun 2019, 2025 Bytes) of package /linux/www/pandoc-2.7.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Haskell source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "Smart.hs": 2.6_vs_2.7.

    1 {-# LANGUAGE NoImplicitPrelude #-}
    2 {-# LANGUAGE OverloadedStrings #-}
    3 {- |
    4    Module      : Tests.Readers.Org.Inline.Smart
    5    Copyright   : © 2014-2019 Albert Krewinkel
    6    License     : GNU GPL, version 2 or above
    7 
    8    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
    9    Stability   : alpha
   10    Portability : portable
   11 
   12 Test smart parsing of quotes, apostrophe, etc.
   13 -}
   14 module Tests.Readers.Org.Inline.Smart (tests) where
   15 
   16 import Prelude
   17 import Data.Text (Text)
   18 import Test.Tasty (TestTree)
   19 import Tests.Helpers ((=?>), purely, test)
   20 import Text.Pandoc (ReaderOptions (readerExtensions),
   21                     Extension (Ext_smart), def, enableExtension,
   22                     getDefaultExtensions, readOrg)
   23 import Text.Pandoc.Builder
   24 
   25 orgSmart :: Text -> Pandoc
   26 orgSmart = purely $
   27   let extensionsSmart = enableExtension Ext_smart (getDefaultExtensions "org")
   28   in readOrg def{ readerExtensions = extensionsSmart }
   29 
   30 tests :: [TestTree]
   31 tests =
   32   [ test orgSmart "quote before ellipses"
   33     ("'...hi'"
   34      =?> para (singleQuoted "…hi"))
   35 
   36   , test orgSmart "apostrophe before emph"
   37     ("D'oh! A l'/aide/!"
   38      =?> para ("D’oh! A l’" <> emph "aide" <> "!"))
   39 
   40   , test orgSmart "apostrophe in French"
   41     ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
   42      =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
   43 
   44   , test orgSmart "Quotes cannot occur at the end of emphasized text"
   45     ("/say \"yes\"/" =?>
   46      para ("/say" <> space <> doubleQuoted "yes" <> "/"))
   47 
   48   , test orgSmart "Dashes are allowed at the borders of emphasis'"
   49     ("/foo---/" =?>
   50      para (emph "foo—"))
   51 
   52   , test orgSmart "Single quotes can be followed by emphasized text"
   53     ("Singles on the '/meat market/'" =?>
   54      para ("Singles on the " <> singleQuoted (emph "meat market")))
   55 
   56   , test orgSmart "Double quotes can be followed by emphasized text"
   57     ("Double income, no kids: \"/DINK/\"" =?>
   58      para ("Double income, no kids: " <> doubleQuoted (emph "DINK")))
   59   ]