git.iko.soy/typeable/pandoc
on master help sign in
Added citation tests.
34d30efNathan Gass
tests/RunTests.hs+20−1
@@ -111,6 +111,11 @@ main = do
111 r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"]
111 r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"]
112 "testsuite.native" "testsuite.native"
112 "testsuite.native" "testsuite.native"
113 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"]
113 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"
114 r12s <- if runLhsTests
119 r12s <- if runLhsTests
115 then mapM runLhsWriterTest lhsWriterFormats
120 then mapM runLhsWriterTest lhsWriterFormats
116 else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return []
121 else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return []
@@ -126,7 +131,8 @@ main = do
126 , r10 -- latex
131 , r10 -- latex
127 , rTextile1 -- textile
132 , rTextile1 -- textile
128 , r11 -- native
133 , r11 -- native
134+ , r15 -- markdown citations
129− ] ++ r12s ++ r13s ++ r14s
135+ ] ++ r12s ++ r13s ++ r14s ++ r16s ++ r17s
130 if all id results
136 if all id results
131 then do
137 then do
132 putStrLn "\nAll tests passed."
138 putStrLn "\nAll tests passed."
@@ -149,6 +155,19 @@ runLhsReaderTest :: String -> IO Bool
149runLhsReaderTest format =
155runLhsReaderTest format =
150 runTest ("(lhs) " ++ format ++ " reader") ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
156 runTest ("(lhs) " ++ format ++ " reader") ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
151
157
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+
152runWriterTest :: String -> IO Bool
171runWriterTest :: String -> IO Bool
153runWriterTest format = do
172runWriterTest format = do
154 r1 <- runTest (format ++ " writer") ["-r", "native", "-s", "-w", format] "testsuite.native" ("writer" <.> format)
173 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 @@
1# Pandoc with citeproc-hs
1# Pandoc with citeproc-hs
2
2
3- [@nonexistent]
3- [@nonexistent]
4+
4- @nonexistent
5- @nonexistent
6+
5- Doe (2005) says blah.
7- Doe (2005) says blah.
8+
6- Doe (2005, 30) says blah.
9- Doe (2005, 30) says blah.
10+
7- Doe (2005, 30, with suffix) says blah.
11- Doe (2005, 30, with suffix) says blah.
12+
8- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.
13- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.
14+
9- In a note.[^1]
15- In a note.[^1]
16+
10- A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3).
17- A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3).
18+
11- Another one (see Doe 2005, 34–35).
19- Another one (see Doe 2005, 34–35).
20+
12- And another one in a note.[^2]
21- And another one in a note.[^2]
22+
13- Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else).
23- Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else).
24+
14- Citation with suffix only (Doe 2005, and nowhere else).
25- Citation with suffix only (Doe 2005, and nowhere else).
26+
15- Now some modifiers.[^3]
27- Now some modifiers.[^3]
16
28
29+- With some markup (*see* Doe 2005, 32).
30+
31+
17# References
32# References
18
33
19Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press.
34Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press.
tests/markdown-citations.ieee.txt+15
@@ -1,19 +1,34 @@
1# Pandoc with citeproc-hs
1# Pandoc with citeproc-hs
2
2
3- [@nonexistent]
3- [@nonexistent]
4+
4- @nonexistent
5- @nonexistent
6+
5- Reference [1] says blah.
7- Reference [1] says blah.
8+
6- Reference [1] says blah.
9- Reference [1] says blah.
10+
7- Reference [1] says blah.
11- Reference [1] says blah.
12+
8- Reference [1] says blah.
13- Reference [1] says blah.
14+
9- In a note.[^1]
15- In a note.[^1]
16+
10- A citation group [1],[3].
17- A citation group [1],[3].
18+
11- Another one [1].
19- Another one [1].
20+
12- And another one in a note.[^2]
21- And another one in a note.[^2]
22+
13- Citation with a suffix and locator [1].
23- Citation with a suffix and locator [1].
24+
14- Citation with suffix only [1].
25- Citation with suffix only [1].
26+
15- Now some modifiers.[^3]
27- Now some modifiers.[^3]
16
28
29+- With some markup [1].
30+
31+
17# References
32# References
18
33
19[1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005.
34[1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005.
tests/markdown-citations.mhra.txt+18
@@ -1,19 +1,34 @@
1# Pandoc with citeproc-hs
1# Pandoc with citeproc-hs
2
2
3- [@nonexistent]
3- [@nonexistent]
4+
4- @nonexistent
5- @nonexistent
6+
5- John Doe[^1] says blah.
7- John Doe[^1] says blah.
8+
6- Doe[^2] says blah.
9- Doe[^2] says blah.
10+
7- Doe[^3] says blah.
11- Doe[^3] says blah.
12+
8- Doe[^4] says blah.
13- Doe[^4] says blah.
14+
9- In a note.[^5]
15- In a note.[^5]
16+
10- A citation group.[^6]
17- A citation group.[^6]
18+
11- Another one.[^7]
19- Another one.[^7]
20+
12- And another one in a note.[^8]
21- And another one in a note.[^8]
22+
13- Citation with a suffix and locator.[^9]
23- Citation with a suffix and locator.[^9]
24+
14- Citation with suffix only.[^10]
25- Citation with suffix only.[^10]
26+
15- Now some modifiers.[^11]
27- Now some modifiers.[^11]
16
28
29+- With some markup.[^12]
30+
31+
17# References
32# References
18
33
19Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34.
34Doe, 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
54
69
55[^11]:
70[^11]:
56 Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44).
71 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 @@
1# Pandoc with citeproc-hs
1# Pandoc with citeproc-hs
2
2
3−- [@nonexistent]
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]
17
4
18−[^1]:
5+- @nonexistent
19− A citation without locators [@item3].
20
6
21−[^2]:
7+- @item1 says blah.
22− Some citations [see @item2 chap. 3; @item3; @item1].
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**].
23
31
24−[^3]:
25− Like a citation without author: [-@item1], and now Doe with a
26− locator [-@item2, p. 44].
27
32
28# References
33# References
29
34
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}