aboutsummaryrefslogtreecommitdiff
path: root/test/Tests/Readers/Org/Inline/Note.hs
blob: c37133d5455541ea2cbcdd1f99f426742019e360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{-# LANGUAGE OverloadedStrings #-}
{- |
   Module      : Tests.Readers.Org.Inline.Note
   Copyright   : © 2014-2021 Albert Krewinkel
   License     : GNU GPL, version 2 or above

   Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
   Stability   : alpha
   Portability : portable

Test parsing of footnotes in org input.
-}
module Tests.Readers.Org.Inline.Note (tests) where

import Test.Tasty (TestTree)
import Tests.Helpers ((=?>))
import Tests.Readers.Org.Shared ((=:))
import Text.Pandoc.Builder
import qualified Data.Text as T

tests :: [TestTree]
tests =
  [ "Footnote" =:
      T.unlines [ "A footnote[1]"
                , ""
                , "[1] First paragraph"
                , ""
                , "second paragraph"
                ] =?>
      para (mconcat
            [ "A", space, "footnote"
            , note $ mconcat [ para ("First" <> space <> "paragraph")
                             , para ("second" <> space <> "paragraph")
                             ]
            ])

  , "Two footnotes" =:
      T.unlines [ "Footnotes[fn:1][fn:2]"
                , ""
                , "[fn:1] First note."
                , ""
                , "[fn:2] Second note."
                ] =?>
      para (mconcat
            [ "Footnotes"
            , note $ para ("First" <> space <> "note.")
            , note $ para ("Second" <> space <> "note.")
            ])

  , "Emphasized text before footnote" =:
      T.unlines [ "/text/[fn:1]"
                , ""
                , "[fn:1] unicorn"
                ] =?>
      para (mconcat
           [ emph "text"
           , note . para $ "unicorn"
           ])

  , "Footnote that starts with emphasized text" =:
      T.unlines [ "text[fn:1]"
                , ""
                , "[fn:1] /emphasized/"
                ] =?>
      para (mconcat
           [ "text"
           , note . para $ emph "emphasized"
           ])

  , "Footnote followed by header" =:
      T.unlines [ "Another note[fn:yay]"
                , ""
                , "[fn:yay] This is great!"
                , ""
                , "** Headline"
                ] =?>
      mconcat
      [ para (mconcat
              [ "Another", space, "note"
              , note $ para ("This" <> space <> "is" <> space <> "great!")
              ])
      , headerWith ("headline", [], []) 2 "Headline"
      ]

  , "Footnote followed by two blank lines" =:
      T.unlines [ "footnote[fn:blanklines]"
                , ""
                , "[fn:blanklines] followed by blank lines"
                , ""
                , ""
                , "next"
                ] =?>
      mconcat
      [ para ("footnote" <> note (para "followed by blank lines"))
      , para "next"
      ]
  ]