@@ -40,5 +40,70 @@ tests = [ testGroup "basic"
4040 "\\section{text \\href{/url}{link}}" =?>
4141 header 1 ("text" +++ space +++ link "/url" "" "link")
4242 ]
43+
44+ , testGroup "citations"
45+ [ natbibCitations
46+ , biblatexCitations
47+ ]
4348 ]
4449
50+baseCitation :: Citation
51+baseCitation = Citation{ citationId = "item1"
52+ , citationPrefix = []
53+ , citationSuffix = []
54+ , citationMode = AuthorInText
55+ , citationNoteNum = 0
56+ , citationHash = 0 }
57+
58+natbibCitations :: Test
59+natbibCitations = testGroup "natbib"
60+ [ "citet" =: "\\citet{item1}"
61+ =?> para (cite [baseCitation] empty)
62+ , "suffix" =: "\\citet[p.~30]{item1}"
63+ =?> para
64+ (cite [baseCitation{ citationSuffix = toList $ text "p.\160\&30" }] empty)
65+ , "suffix long" =: "\\citet[p.~30, with suffix]{item1}"
66+ =?> para (cite [baseCitation{ citationSuffix =
67+ toList $ text "p.\160\&30, with suffix" }] empty)
68+ , "multiple" =: "\\citeauthor{item1} \\citetext{\\citeyear{item1}; \\citeyear[p.~30]{item2}; \\citealp[see also][]{item3}}"
69+ =?> para (cite [baseCitation{ citationMode = AuthorInText }
70+ ,baseCitation{ citationMode = SuppressAuthor
71+ , citationSuffix = [Str "p.\160\&30"]
72+ , citationId = "item2" }
73+ ,baseCitation{ citationId = "item3"
74+ , citationPrefix = [Str "see",Space,Str "also"]
75+ , citationMode = NormalCitation }
76+ ] empty)
77+ , "group" =: "\\citetext{\\citealp[see][p.~34--35]{item1}; \\citealp[also][chap. 3]{item3}}"
78+ =?> para (cite [baseCitation{ citationMode = NormalCitation
79+ , citationPrefix = [Str "see"]
80+ , citationSuffix = [Str "p.\160\&34",EnDash,Str "35"] }
81+ ,baseCitation{ citationMode = NormalCitation
82+ , citationId = "item3"
83+ , citationPrefix = [Str "also"]
84+ , citationSuffix = [Str "chap.",Space,Str "3"] }
85+ ] empty)
86+ , "suffix and locator" =: "\\citep[pp.~33, 35--37, and nowhere else]{item1}"
87+ =?> para (cite [baseCitation{ citationMode = NormalCitation
88+ , citationSuffix = [Str "pp.\160\&33,",Space,Str "35",EnDash,Str "37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] empty)
89+ , "suffix only" =: "\\citep[and nowhere else]{item1}"
90+ =?> para (cite [baseCitation{ citationMode = NormalCitation
91+ , citationSuffix = toList $ text "and nowhere else" }] empty)
92+ , "no author" =: "\\citeyearpar{item1}, and now Doe with a locator \\citeyearpar[p.~44]{item2}"
93+ =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] empty +++
94+ text ", and now Doe with a locator " +++
95+ cite [baseCitation{ citationMode = SuppressAuthor
96+ , citationSuffix = [Str "p.\160\&44"]
97+ , citationId = "item2" }] empty)
98+ , "markup" =: "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"
99+ =?> para (cite [baseCitation{ citationMode = NormalCitation
100+ , citationPrefix = [Emph [Str "see"]]
101+ , citationSuffix = [Str "p.",Space,
102+ Strong [Str "32"]] }] empty)
103+ ]
104+
105+biblatexCitations :: Test
106+biblatexCitations = testGroup "biblatex"
107+ [
108+ ]
109+