git.iko.soy/typeable/pandoc
on master help sign in
Org reader tests: move citation tests to separate module
6ed7926Albert Krewinkel
pandoc.cabal+1
@@ -649,6 +649,7 @@ test-suite test-pandoc
649 Tests.Readers.Org.Block.Table
649 Tests.Readers.Org.Block.Table
650 Tests.Readers.Org.Directive
650 Tests.Readers.Org.Directive
651 Tests.Readers.Org.Inline
651 Tests.Readers.Org.Inline
652+ Tests.Readers.Org.Inline.Citation
652 Tests.Readers.Org.Inline.Note
653 Tests.Readers.Org.Inline.Note
653 Tests.Readers.Org.Inline.Smart
654 Tests.Readers.Org.Inline.Smart
654 Tests.Readers.Org.Meta
655 Tests.Readers.Org.Meta
test/Tests/Readers/Org/Inline.hs+2−167
@@ -5,10 +5,10 @@ import Data.List (intersperse)
5import Test.Tasty (TestTree, testGroup)
5import Test.Tasty (TestTree, testGroup)
6import Tests.Helpers ((=?>))
6import Tests.Helpers ((=?>))
7import Tests.Readers.Org.Shared ((=:), spcSep)
7import Tests.Readers.Org.Shared ((=:), spcSep)
8−import Text.Pandoc
9import Text.Pandoc.Builder
8import Text.Pandoc.Builder
10import Text.Pandoc.Shared (underlineSpan)
9import Text.Pandoc.Shared (underlineSpan)
11import qualified Data.Text as T
10import qualified Data.Text as T
11+import qualified Tests.Readers.Org.Inline.Citation as Citation
12import qualified Tests.Readers.Org.Inline.Note as Note
12import qualified Tests.Readers.Org.Inline.Note as Note
13import qualified Tests.Readers.Org.Inline.Smart as Smart
13import qualified Tests.Readers.Org.Inline.Smart as Smart
14
14
@@ -288,161 +288,6 @@ tests =
288 )
288 )
289 "echo $HOME")
289 "echo $HOME")
290
290
291− , "Citation" =:
292− "[@nonexistent]" =?>
293− let citation = Citation
294− { citationId = "nonexistent"
295− , citationPrefix = []
296− , citationSuffix = []
297− , citationMode = NormalCitation
298− , citationNoteNum = 0
299− , citationHash = 0}
300− in (para $ cite [citation] "[@nonexistent]")
301−
302− , "Citation containing text" =:
303− "[see @item1 p. 34-35]" =?>
304− let citation = Citation
305− { citationId = "item1"
306− , citationPrefix = [Str "see"]
307− , citationSuffix = [Space ,Str "p.",Space,Str "34-35"]
308− , citationMode = NormalCitation
309− , citationNoteNum = 0
310− , citationHash = 0}
311− in (para $ cite [citation] "[see @item1 p. 34-35]")
312−
313− , "Org-ref simple citation" =:
314− "cite:pandoc" =?>
315− let citation = Citation
316− { citationId = "pandoc"
317− , citationPrefix = mempty
318− , citationSuffix = mempty
319− , citationMode = AuthorInText
320− , citationNoteNum = 0
321− , citationHash = 0
322− }
323− in (para $ cite [citation] "cite:pandoc")
324−
325− , "Org-ref simple citation with underscores" =:
326− "cite:pandoc_org_ref" =?>
327− let citation = Citation
328− { citationId = "pandoc_org_ref"
329− , citationPrefix = mempty
330− , citationSuffix = mempty
331− , citationMode = AuthorInText
332− , citationNoteNum = 0
333− , citationHash = 0
334− }
335− in (para $ cite [citation] "cite:pandoc_org_ref")
336−
337− , "Org-ref simple citation succeeded by comma" =:
338− "cite:pandoc," =?>
339− let citation = Citation
340− { citationId = "pandoc"
341− , citationPrefix = mempty
342− , citationSuffix = mempty
343− , citationMode = AuthorInText
344− , citationNoteNum = 0
345− , citationHash = 0
346− }
347− in (para $ cite [citation] "cite:pandoc" <> str ",")
348−
349− , "Org-ref simple citation succeeded by dot" =:
350− "cite:pandoc." =?>
351− let citation = Citation
352− { citationId = "pandoc"
353− , citationPrefix = mempty
354− , citationSuffix = mempty
355− , citationMode = AuthorInText
356− , citationNoteNum = 0
357− , citationHash = 0
358− }
359− in (para $ cite [citation] "cite:pandoc" <> str ".")
360−
361− , "Org-ref simple citation succeeded by colon" =:
362− "cite:pandoc:" =?>
363− let citation = Citation
364− { citationId = "pandoc"
365− , citationPrefix = mempty
366− , citationSuffix = mempty
367− , citationMode = AuthorInText
368− , citationNoteNum = 0
369− , citationHash = 0
370− }
371− in (para $ cite [citation] "cite:pandoc" <> str ":")
372−
373− , "Org-ref simple citep citation" =:
374− "citep:pandoc" =?>
375− let citation = Citation
376− { citationId = "pandoc"
377− , citationPrefix = mempty
378− , citationSuffix = mempty
379− , citationMode = NormalCitation
380− , citationNoteNum = 0
381− , citationHash = 0
382− }
383− in (para $ cite [citation] "citep:pandoc")
384−
385− , "Org-ref extended citation" =:
386− "[[citep:Dominik201408][See page 20::, for example]]" =?>
387− let citation = Citation
388− { citationId = "Dominik201408"
389− , citationPrefix = toList "See page 20"
390− , citationSuffix = toList ", for example"
391− , citationMode = NormalCitation
392− , citationNoteNum = 0
393− , citationHash = 0
394− }
395− in (para $ cite [citation] "[[citep:Dominik201408][See page 20::, for example]]")
396−
397− , testGroup "Berkeley-style citations" $
398− let pandocCite = Citation
399− { citationId = "Pandoc"
400− , citationPrefix = mempty
401− , citationSuffix = mempty
402− , citationMode = NormalCitation
403− , citationNoteNum = 0
404− , citationHash = 0
405− }
406− pandocInText = pandocCite { citationMode = AuthorInText }
407− dominikCite = Citation
408− { citationId = "Dominik201408"
409− , citationPrefix = mempty
410− , citationSuffix = mempty
411− , citationMode = NormalCitation
412− , citationNoteNum = 0
413− , citationHash = 0
414− }
415− dominikInText = dominikCite { citationMode = AuthorInText }
416− in [
417− "Berkeley-style in-text citation" =:
418− "See @Dominik201408." =?>
419− para ("See "
420− <> cite [dominikInText] "@Dominik201408"
421− <> ".")
422−
423− , "Berkeley-style parenthetical citation list" =:
424− "[(cite): see; @Dominik201408;also @Pandoc; and others]" =?>
425− let pandocCite' = pandocCite {
426− citationPrefix = toList "also"
427− , citationSuffix = toList "and others"
428− }
429− dominikCite' = dominikCite {
430− citationPrefix = toList "see"
431− }
432− in (para $ cite [dominikCite', pandocCite'] "")
433−
434− , "Berkeley-style plain citation list" =:
435− "[cite: See; @Dominik201408; and @Pandoc; and others]" =?>
436− let pandocCite' = pandocInText {
437− citationPrefix = toList "and"
438− }
439− in (para $ "See "
440− <> cite [dominikInText] ""
441− <> "," <> space
442− <> cite [pandocCite'] ""
443− <> "," <> space <> "and others")
444− ]
445−
446 , "Inline LaTeX symbol" =:
291 , "Inline LaTeX symbol" =:
447 "\\dots" =?>
292 "\\dots" =?>
448 para "…"
293 para "…"
@@ -483,17 +328,6 @@ tests =
483 "\\ForAll \\Auml" =?>
328 "\\ForAll \\Auml" =?>
484 para "∀ Ä"
329 para "∀ Ä"
485
330
486− , "LaTeX citation" =:
487− "\\cite{Coffee}" =?>
488− let citation = Citation
489− { citationId = "Coffee"
490− , citationPrefix = []
491− , citationSuffix = []
492− , citationMode = NormalCitation
493− , citationNoteNum = 0
494− , citationHash = 0}
495− in (para . cite [citation] $ rawInline "latex" "\\cite{Coffee}")
496−
497 , "Macro" =:
331 , "Macro" =:
498 T.unlines [ "#+MACRO: HELLO /Hello, $1/"
332 T.unlines [ "#+MACRO: HELLO /Hello, $1/"
499 , "{{{HELLO(World)}}}"
333 , "{{{HELLO(World)}}}"
@@ -512,6 +346,7 @@ tests =
512 ] =?>
346 ] =?>
513 para "Foo Bar"
347 para "Foo Bar"
514
348
349+ , testGroup "Citations" Citation.tests
515 , testGroup "Footnotes" Note.tests
350 , testGroup "Footnotes" Note.tests
516 , testGroup "Smart punctuation" Smart.tests
351 , testGroup "Smart punctuation" Smart.tests
517 ]
352 ]
test/Tests/Readers/Org/Inline/Citation.hsnew file+179
@@ -0,0 +1,179 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Tests.Readers.Org.Inline.Citation (tests) where
3+
4+import Test.Tasty (TestTree, testGroup)
5+import Tests.Helpers ((=?>))
6+import Tests.Readers.Org.Shared ((=:))
7+import Text.Pandoc.Builder
8+
9+tests :: [TestTree]
10+tests =
11+ [ testGroup "Markdown-style citations"
12+ [ "Citation" =:
13+ "[@nonexistent]" =?>
14+ let citation = Citation
15+ { citationId = "nonexistent"
16+ , citationPrefix = []
17+ , citationSuffix = []
18+ , citationMode = NormalCitation
19+ , citationNoteNum = 0
20+ , citationHash = 0}
21+ in (para $ cite [citation] "[@nonexistent]")
22+
23+ , "Citation containing text" =:
24+ "[see @item1 p. 34-35]" =?>
25+ let citation = Citation
26+ { citationId = "item1"
27+ , citationPrefix = [Str "see"]
28+ , citationSuffix = [Space ,Str "p.",Space,Str "34-35"]
29+ , citationMode = NormalCitation
30+ , citationNoteNum = 0
31+ , citationHash = 0}
32+ in (para $ cite [citation] "[see @item1 p. 34-35]")
33+ ]
34+
35+ , testGroup "org-ref citations"
36+ [ "simple citation" =:
37+ "cite:pandoc" =?>
38+ let citation = Citation
39+ { citationId = "pandoc"
40+ , citationPrefix = mempty
41+ , citationSuffix = mempty
42+ , citationMode = AuthorInText
43+ , citationNoteNum = 0
44+ , citationHash = 0
45+ }
46+ in (para $ cite [citation] "cite:pandoc")
47+
48+ , "simple citation with underscores" =:
49+ "cite:pandoc_org_ref" =?>
50+ let citation = Citation
51+ { citationId = "pandoc_org_ref"
52+ , citationPrefix = mempty
53+ , citationSuffix = mempty
54+ , citationMode = AuthorInText
55+ , citationNoteNum = 0
56+ , citationHash = 0
57+ }
58+ in (para $ cite [citation] "cite:pandoc_org_ref")
59+
60+ , "simple citation succeeded by comma" =:
61+ "cite:pandoc," =?>
62+ let citation = Citation
63+ { citationId = "pandoc"
64+ , citationPrefix = mempty
65+ , citationSuffix = mempty
66+ , citationMode = AuthorInText
67+ , citationNoteNum = 0
68+ , citationHash = 0
69+ }
70+ in (para $ cite [citation] "cite:pandoc" <> str ",")
71+
72+ , "simple citation succeeded by dot" =:
73+ "cite:pandoc." =?>
74+ let citation = Citation
75+ { citationId = "pandoc"
76+ , citationPrefix = mempty
77+ , citationSuffix = mempty
78+ , citationMode = AuthorInText
79+ , citationNoteNum = 0
80+ , citationHash = 0
81+ }
82+ in (para $ cite [citation] "cite:pandoc" <> str ".")
83+
84+ , "simple citation succeeded by colon" =:
85+ "cite:pandoc:" =?>
86+ let citation = Citation
87+ { citationId = "pandoc"
88+ , citationPrefix = mempty
89+ , citationSuffix = mempty
90+ , citationMode = AuthorInText
91+ , citationNoteNum = 0
92+ , citationHash = 0
93+ }
94+ in (para $ cite [citation] "cite:pandoc" <> str ":")
95+
96+ , "simple citep citation" =:
97+ "citep:pandoc" =?>
98+ let citation = Citation
99+ { citationId = "pandoc"
100+ , citationPrefix = mempty
101+ , citationSuffix = mempty
102+ , citationMode = NormalCitation
103+ , citationNoteNum = 0
104+ , citationHash = 0
105+ }
106+ in (para $ cite [citation] "citep:pandoc")
107+
108+ , "extended citation" =:
109+ "[[citep:Dominik201408][See page 20::, for example]]" =?>
110+ let citation = Citation
111+ { citationId = "Dominik201408"
112+ , citationPrefix = toList "See page 20"
113+ , citationSuffix = toList ", for example"
114+ , citationMode = NormalCitation
115+ , citationNoteNum = 0
116+ , citationHash = 0
117+ }
118+ in (para $ cite [citation] "[[citep:Dominik201408][See page 20::, for example]]")
119+ ]
120+
121+ , testGroup "Berkeley-style citations" $
122+ let pandocCite = Citation
123+ { citationId = "Pandoc"
124+ , citationPrefix = mempty
125+ , citationSuffix = mempty
126+ , citationMode = NormalCitation
127+ , citationNoteNum = 0
128+ , citationHash = 0
129+ }
130+ pandocInText = pandocCite { citationMode = AuthorInText }
131+ dominikCite = Citation
132+ { citationId = "Dominik201408"
133+ , citationPrefix = mempty
134+ , citationSuffix = mempty
135+ , citationMode = NormalCitation
136+ , citationNoteNum = 0
137+ , citationHash = 0
138+ }
139+ dominikInText = dominikCite { citationMode = AuthorInText }
140+ in
141+ [ "Berkeley-style in-text citation" =:
142+ "See @Dominik201408." =?>
143+ para ("See "
144+ <> cite [dominikInText] "@Dominik201408"
145+ <> ".")
146+
147+ , "Berkeley-style parenthetical citation list" =:
148+ "[(cite): see; @Dominik201408;also @Pandoc; and others]" =?>
149+ let pandocCite' = pandocCite {
150+ citationPrefix = toList "also"
151+ , citationSuffix = toList "and others"
152+ }
153+ dominikCite' = dominikCite {
154+ citationPrefix = toList "see"
155+ }
156+ in (para $ cite [dominikCite', pandocCite'] "")
157+
158+ , "Berkeley-style plain citation list" =:
159+ "[cite: See; @Dominik201408; and @Pandoc; and others]" =?>
160+ let pandocCite' = pandocInText { citationPrefix = toList "and" }
161+ in (para $ "See "
162+ <> cite [dominikInText] ""
163+ <> "," <> space
164+ <> cite [pandocCite'] ""
165+ <> "," <> space <> "and others")
166+ ]
167+
168+ , "LaTeX citation" =:
169+ "\\cite{Coffee}" =?>
170+ let citation = Citation
171+ { citationId = "Coffee"
172+ , citationPrefix = []
173+ , citationSuffix = []
174+ , citationMode = NormalCitation
175+ , citationNoteNum = 0
176+ , citationHash = 0}
177+ in (para . cite [citation] $ rawInline "latex" "\\cite{Coffee}")
178+
179+ ]