git.iko.soy/typeable/pandoc
on master help sign in
Added citation tests.

Added tests for latex citation writer and reader, markdown citation writer and additional markup in citations.

commit34d30efc5c58b8f60c44f5db369a3056780f654a authorNathan Gass <gass@search.ch> dateTue 14 Dec 2010, 09:54 (16 years ago) parent128cf46
7 files changed+245−22
tests/RunTests.hs+20−1 tests/biblatex-citations.latex+70 tests/markdown-citations.chicago-author-date.txt+15 tests/markdown-citations.ieee.txt+15 tests/markdown-citations.mhra.txt+18 tests/markdown-citations.txt+35−21 tests/natbib-citations.latex+72
tests/RunTests.hs+20−1
@@ -111,6 +111,11 @@ main = do
111111 r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"]
112112 "testsuite.native" "testsuite.native"
113113 r14s <- mapM (\style -> runTest ("markdown reader (citations) (" ++ style ++ ")") ["-r", "markdown", "-w", "markdown", "--bibliography", "biblio.bib", "--csl", style ++ ".csl", "--no-wrap"] "markdown-citations.txt" ("markdown-citations." ++ style ++ ".txt")) ["chicago-author-date","ieee","mhra"]
114+ let citopts = ["--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl", "--no-citeproc"]
115+ r15 <- runTest "markdown writer (citations)" (["-r", "markdown", "-w", "markdown"] ++ citopts)
116+ "markdown-citations.txt" "markdown-citations.txt"
117+ r16s <- runLatexCitationTests citopts "biblatex"
118+ r17s <- runLatexCitationTests citopts "natbib"
114119 r12s <- if runLhsTests
115120 then mapM runLhsWriterTest lhsWriterFormats
116121 else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return []
@@ -126,7 +131,8 @@ main = do
126131 , r10 -- latex
127132 , rTextile1 -- textile
128133 , r11 -- native
129− ] ++ r12s ++ r13s ++ r14s
134+ , r15 -- markdown citations
135+ ] ++ r12s ++ r13s ++ r14s ++ r16s ++ r17s
130136 if all id results
131137 then do
132138 putStrLn "\nAll tests passed."
@@ -149,6 +155,19 @@ runLhsReaderTest :: String -> IO Bool
149155runLhsReaderTest format =
150156 runTest ("(lhs) " ++ format ++ " reader") ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
151157
158+
159+runLatexCitationTests :: [String] -> String -> IO [Bool]
160+runLatexCitationTests o n
161+ = sequence [ rt ("latex reader (" ++ n ++ " citations)") (["-r", "latex", "-w", "markdown", "-s"] ++ o')
162+ f "markdown-citations.txt"
163+ , rt ("latex writer (" ++ n ++ " citations)") (["-r", "markdown", "-w", "latex", "-s"] ++ o')
164+ "markdown-citations.txt" f
165+ ]
166+ where
167+ o' = o ++ ["--" ++ n]
168+ f = n ++ "-citations.latex"
169+ rt = runTest
170+
152171runWriterTest :: String -> IO Bool
153172runWriterTest format = do
154173 r1 <- runTest (format ++ " writer") ["-r", "native", "-s", "-w", format] "testsuite.native" ("writer" <.> format)
tests/biblatex-citations.latexnew file+70
@@ -0,0 +1,70 @@
1+\documentclass{article}
2+\usepackage{amssymb,amsmath}
3+\usepackage[mathletters]{ucs}
4+\usepackage[utf8x]{inputenc}
5+\usepackage{biblatex}
6+\bibliography{biblio}
7+\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
8+\setlength{\parindent}{0pt}
9+\setlength{\parskip}{6pt plus 2pt minus 1pt}
10+\setcounter{secnumdepth}{0}
11+
12+
13+\begin{document}
14+
15+\section{Pandoc with citeproc-hs}
16+
17+\begin{itemize}
18+\item
19+ {[}@nonexistent{]}
20+
21+\item
22+ @nonexistent
23+
24+\item
25+ \textcite{item1} says blah.
26+
27+\item
28+ \textcite[p.~30]{item1} says blah.
29+
30+\item
31+ \textcite[p.~30, with suffix]{item1} says blah.
32+
33+\item
34+ \textcites{item1}[p.~30]{item2}[see also][]{item3} says blah.
35+
36+\item
37+ In a note.%
38+ \footnote{A citation without locators \autocite{item3}.}
39+
40+\item
41+ A citation group
42+ \autocites[see][, p.~34--35]{item1}[also][chap. 3]{item3}.
43+
44+\item
45+ Another one \autocite[see][p.~34--35]{item1}.
46+
47+\item
48+ And another one in a note.%
49+ \footnote{Some citations \autocites[see][chap. 3]{item2}{item3}{item1}.}
50+
51+\item
52+ Citation with a suffix and locator
53+ \autocite[, pp.~33, 35--37, and nowhere else]{item1}.
54+
55+\item
56+ Citation with suffix only \autocite[, and nowhere else]{item1}.
57+
58+\item
59+ Now some modifiers.%
60+ \footnote{Like a citation without author: \autocite*{item1}, and now Doe with
61+a locator \autocite*[p.~44]{item2}.}
62+
63+\item
64+ With some markup \autocite[\emph{see}][p. \textbf{32}]{item1}.
65+
66+\end{itemize}
67+\section{References}
68+\printbibliography
69+
70+\end{document}
tests/markdown-citations.chicago-author-date.txt+15
@@ -1,19 +1,34 @@
11# Pandoc with citeproc-hs
22
33- [@nonexistent]
4+
45- @nonexistent
6+
57- Doe (2005) says blah.
8+
69- Doe (2005, 30) says blah.
10+
711- Doe (2005, 30, with suffix) says blah.
12+
813- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.
14+
915- In a note.[^1]
16+
1017- A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3).
18+
1119- Another one (see Doe 2005, 34–35).
20+
1221- And another one in a note.[^2]
22+
1323- Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else).
24+
1425- Citation with suffix only (Doe 2005, and nowhere else).
26+
1527- Now some modifiers.[^3]
1628
29+- With some markup (*see* Doe 2005, 32).
30+
31+
1732# References
1833
1934Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press.
tests/markdown-citations.ieee.txt+15
@@ -1,19 +1,34 @@
11# Pandoc with citeproc-hs
22
33- [@nonexistent]
4+
45- @nonexistent
6+
57- Reference [1] says blah.
8+
69- Reference [1] says blah.
10+
711- Reference [1] says blah.
12+
813- Reference [1] says blah.
14+
915- In a note.[^1]
16+
1017- A citation group [1],[3].
18+
1119- Another one [1].
20+
1221- And another one in a note.[^2]
22+
1323- Citation with a suffix and locator [1].
24+
1425- Citation with suffix only [1].
26+
1527- Now some modifiers.[^3]
1628
29+- With some markup [1].
30+
31+
1732# References
1833
1934[1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005.
tests/markdown-citations.mhra.txt+18
@@ -1,19 +1,34 @@
11# Pandoc with citeproc-hs
22
33- [@nonexistent]
4+
45- @nonexistent
6+
57- John Doe[^1] says blah.
8+
69- Doe[^2] says blah.
10+
711- Doe[^3] says blah.
12+
813- Doe[^4] says blah.
14+
915- In a note.[^5]
16+
1017- A citation group.[^6]
18+
1119- Another one.[^7]
20+
1221- And another one in a note.[^8]
22+
1323- Citation with a suffix and locator.[^9]
24+
1425- Citation with suffix only.[^10]
26+
1527- Now some modifiers.[^11]
1628
29+- With some markup.[^12]
30+
31+
1732# References
1833
1934Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34.
@@ -54,3 +69,6 @@ Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed by Sam Smi
5469
5570[^11]:
5671 Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44).
72+
73+[^12]:
74+ *See* Doe, First Book, p. 32.
tests/markdown-citations.txt+35−21
@@ -1,29 +1,43 @@
11# Pandoc with citeproc-hs
22
3−- [@nonexistent]
4−- @nonexistent
5−- @item1 says blah.
6−- @item1 [p. 30] says blah.
7−- @item1 [p. 30, with suffix] says blah.
8−- @item1 [-@item2 p. 30; see also @item3] says blah.
9−- In a note.[^1]
10−- A citation group [see @item1, p. 34-35; also @item3 chap. 3].
11−- Another one [see
12− @item1 p. 34-35].
13−- And another one in a note.[^2]
14−- Citation with a suffix and locator [@item1, pp. 33, 35-37, and nowhere else].
15−- Citation with suffix only [@item1, and nowhere else].
16−- Now some modifiers.[^3]
3+- [@nonexistent]
174
18−[^1]:
19− A citation without locators [@item3].
5+- @nonexistent
206
21−[^2]:
22− Some citations [see @item2 chap. 3; @item3; @item1].
7+- @item1 says blah.
8+
9+- @item1 [p. 30] says blah.
10+
11+- @item1 [p. 30, with suffix] says blah.
12+
13+- @item1 [-@item2 p. 30; see also @item3] says blah.
14+
15+- In a note.[^1]
16+
17+- A citation group [see @item1, p. 34-35; also @item3 chap. 3].
18+
19+- Another one [see @item1 p. 34-35].
20+
21+- And another one in a note.[^2]
22+
23+- Citation with a suffix and locator
24+ [@item1, pp. 33, 35-37, and nowhere else].
25+
26+- Citation with suffix only [@item1, and nowhere else].
27+
28+- Now some modifiers.[^3]
29+
30+- With some markup [*see* @item1 p. **32**].
2331
24−[^3]:
25− Like a citation without author: [-@item1], and now Doe with a
26− locator [-@item2, p. 44].
2732
2833# References
2934
35+[^1]:
36+ A citation without locators [@item3].
37+
38+[^2]:
39+ Some citations [see @item2 chap. 3; @item3; @item1].
40+
41+[^3]:
42+ Like a citation without author: [-@item1], and now Doe with a
43+ locator [-@item2 p. 44].
tests/natbib-citations.latexnew file+72
@@ -0,0 +1,72 @@
1+\documentclass{article}
2+\usepackage{amssymb,amsmath}
3+\usepackage[mathletters]{ucs}
4+\usepackage[utf8x]{inputenc}
5+\usepackage{natbib}
6+\bibliographystyle{plainnat}
7+\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
8+\setlength{\parindent}{0pt}
9+\setlength{\parskip}{6pt plus 2pt minus 1pt}
10+\setcounter{secnumdepth}{0}
11+
12+
13+\begin{document}
14+
15+\section{Pandoc with citeproc-hs}
16+
17+\begin{itemize}
18+\item
19+ {[}@nonexistent{]}
20+
21+\item
22+ @nonexistent
23+
24+\item
25+ \citet{item1} says blah.
26+
27+\item
28+ \citet[p.~30]{item1} says blah.
29+
30+\item
31+ \citet[p.~30, with suffix]{item1} says blah.
32+
33+\item
34+ \citeauthor{item1} \citetext{\citeyear{item1}; \citeyear[p.~30]{item2}; \citealp[see also][]{item3}}
35+ says blah.
36+
37+\item
38+ In a note.%
39+ \footnote{A citation without locators \citep{item3}.}
40+
41+\item
42+ A citation group
43+ \citetext{\citealp[see][, p.~34--35]{item1}; \citealp[also][chap. 3]{item3}}.
44+
45+\item
46+ Another one \citep[see][p.~34--35]{item1}.
47+
48+\item
49+ And another one in a note.%
50+ \footnote{Some citations
51+\citetext{\citealp[see][chap. 3]{item2}; \citealp{item3}; \citealp{item1}}.}
52+
53+\item
54+ Citation with a suffix and locator
55+ \citep[, pp.~33, 35--37, and nowhere else]{item1}.
56+
57+\item
58+ Citation with suffix only \citep[, and nowhere else]{item1}.
59+
60+\item
61+ Now some modifiers.%
62+ \footnote{Like a citation without author: \citeyearpar{item1}, and now Doe
63+with a locator \citeyearpar[p.~44]{item2}.}
64+
65+\item
66+ With some markup \citep[\emph{see}][p. \textbf{32}]{item1}.
67+
68+\end{itemize}
69+\section{References}
70+\bibliography{biblio}
71+
72+\end{document}