Added citation tests.

Added tests for latex  citation writer and reader,
markdown citation writer and additional markup in citations.
This commit is contained in:
Nathan Gass 2010-12-14 09:54:13 +01:00 committed by John MacFarlane
parent 128cf46089
commit 34d30efc5c
7 changed files with 245 additions and 22 deletions

View file

@ -111,6 +111,11 @@ main = do
r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"] r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"]
"testsuite.native" "testsuite.native" "testsuite.native" "testsuite.native"
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"] 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"]
let citopts = ["--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl", "--no-citeproc"]
r15 <- runTest "markdown writer (citations)" (["-r", "markdown", "-w", "markdown"] ++ citopts)
"markdown-citations.txt" "markdown-citations.txt"
r16s <- runLatexCitationTests citopts "biblatex"
r17s <- runLatexCitationTests citopts "natbib"
r12s <- if runLhsTests r12s <- if runLhsTests
then mapM runLhsWriterTest lhsWriterFormats then mapM runLhsWriterTest lhsWriterFormats
else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return [] else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return []
@ -126,7 +131,8 @@ main = do
, r10 -- latex , r10 -- latex
, rTextile1 -- textile , rTextile1 -- textile
, r11 -- native , r11 -- native
] ++ r12s ++ r13s ++ r14s , r15 -- markdown citations
] ++ r12s ++ r13s ++ r14s ++ r16s ++ r17s
if all id results if all id results
then do then do
putStrLn "\nAll tests passed." putStrLn "\nAll tests passed."
@ -149,6 +155,19 @@ runLhsReaderTest :: String -> IO Bool
runLhsReaderTest format = runLhsReaderTest format =
runTest ("(lhs) " ++ format ++ " reader") ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs" runTest ("(lhs) " ++ format ++ " reader") ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
runLatexCitationTests :: [String] -> String -> IO [Bool]
runLatexCitationTests o n
= sequence [ rt ("latex reader (" ++ n ++ " citations)") (["-r", "latex", "-w", "markdown", "-s"] ++ o')
f "markdown-citations.txt"
, rt ("latex writer (" ++ n ++ " citations)") (["-r", "markdown", "-w", "latex", "-s"] ++ o')
"markdown-citations.txt" f
]
where
o' = o ++ ["--" ++ n]
f = n ++ "-citations.latex"
rt = runTest
runWriterTest :: String -> IO Bool runWriterTest :: String -> IO Bool
runWriterTest format = do runWriterTest format = do
r1 <- runTest (format ++ " writer") ["-r", "native", "-s", "-w", format] "testsuite.native" ("writer" <.> format) r1 <- runTest (format ++ " writer") ["-r", "native", "-s", "-w", format] "testsuite.native" ("writer" <.> format)

View file

@ -0,0 +1,70 @@
\documentclass{article}
\usepackage{amssymb,amsmath}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{biblatex}
\bibliography{biblio}
\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setcounter{secnumdepth}{0}
\begin{document}
\section{Pandoc with citeproc-hs}
\begin{itemize}
\item
{[}@nonexistent{]}
\item
@nonexistent
\item
\textcite{item1} says blah.
\item
\textcite[p.~30]{item1} says blah.
\item
\textcite[p.~30, with suffix]{item1} says blah.
\item
\textcites{item1}[p.~30]{item2}[see also][]{item3} says blah.
\item
In a note.%
\footnote{A citation without locators \autocite{item3}.}
\item
A citation group
\autocites[see][, p.~34--35]{item1}[also][chap. 3]{item3}.
\item
Another one \autocite[see][p.~34--35]{item1}.
\item
And another one in a note.%
\footnote{Some citations \autocites[see][chap. 3]{item2}{item3}{item1}.}
\item
Citation with a suffix and locator
\autocite[, pp.~33, 35--37, and nowhere else]{item1}.
\item
Citation with suffix only \autocite[, and nowhere else]{item1}.
\item
Now some modifiers.%
\footnote{Like a citation without author: \autocite*{item1}, and now Doe with
a locator \autocite*[p.~44]{item2}.}
\item
With some markup \autocite[\emph{see}][p. \textbf{32}]{item1}.
\end{itemize}
\section{References}
\printbibliography
\end{document}

View file

@ -1,19 +1,34 @@
# Pandoc with citeproc-hs # Pandoc with citeproc-hs
- [@nonexistent] - [@nonexistent]
- @nonexistent - @nonexistent
- Doe (2005) says blah. - Doe (2005) says blah.
- Doe (2005, 30) says blah. - Doe (2005, 30) says blah.
- Doe (2005, 30, with suffix) says blah. - Doe (2005, 30, with suffix) says blah.
- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah. - Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.
- In a note.[^1] - In a note.[^1]
- A citation group (see Doe 2005, 3435; also Doe and Roe 2007, chap. 3). - A citation group (see Doe 2005, 3435; also Doe and Roe 2007, chap. 3).
- Another one (see Doe 2005, 3435). - Another one (see Doe 2005, 3435).
- And another one in a note.[^2] - And another one in a note.[^2]
- Citation with a suffix and locator (Doe 2005, 33, 3537, and nowhere else). - Citation with a suffix and locator (Doe 2005, 33, 3537, and nowhere else).
- Citation with suffix only (Doe 2005, and nowhere else). - Citation with suffix only (Doe 2005, and nowhere else).
- Now some modifiers.[^3] - Now some modifiers.[^3]
- With some markup (*see* Doe 2005, 32).
# References # References
Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press. Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press.

View file

@ -1,19 +1,34 @@
# Pandoc with citeproc-hs # Pandoc with citeproc-hs
- [@nonexistent] - [@nonexistent]
- @nonexistent - @nonexistent
- Reference [1] says blah. - Reference [1] says blah.
- Reference [1] says blah. - Reference [1] says blah.
- Reference [1] says blah. - Reference [1] says blah.
- Reference [1] says blah. - Reference [1] says blah.
- In a note.[^1] - In a note.[^1]
- A citation group [1],[3]. - A citation group [1],[3].
- Another one [1]. - Another one [1].
- And another one in a note.[^2] - And another one in a note.[^2]
- Citation with a suffix and locator [1]. - Citation with a suffix and locator [1].
- Citation with suffix only [1]. - Citation with suffix only [1].
- Now some modifiers.[^3] - Now some modifiers.[^3]
- With some markup [1].
# References # References
[1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005. [1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005.

View file

@ -1,19 +1,34 @@
# Pandoc with citeproc-hs # Pandoc with citeproc-hs
- [@nonexistent] - [@nonexistent]
- @nonexistent - @nonexistent
- John Doe[^1] says blah. - John Doe[^1] says blah.
- Doe[^2] says blah. - Doe[^2] says blah.
- Doe[^3] says blah. - Doe[^3] says blah.
- Doe[^4] says blah. - Doe[^4] says blah.
- In a note.[^5] - In a note.[^5]
- A citation group.[^6] - A citation group.[^6]
- Another one.[^7] - Another one.[^7]
- And another one in a note.[^8] - And another one in a note.[^8]
- Citation with a suffix and locator.[^9] - Citation with a suffix and locator.[^9]
- Citation with suffix only.[^10] - Citation with suffix only.[^10]
- Now some modifiers.[^11] - Now some modifiers.[^11]
- With some markup.[^12]
# References # References
Doe, John, Article, *Journal of Generic Studies*, 6 (2006), 33-34. Doe, 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
[^11]: [^11]:
Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44). Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44).
[^12]:
*See* Doe, First Book, p. 32.

View file

@ -1,29 +1,43 @@
# Pandoc with citeproc-hs # Pandoc with citeproc-hs
- [@nonexistent] - [@nonexistent]
- @nonexistent
- @item1 says blah.
- @item1 [p. 30] says blah.
- @item1 [p. 30, with suffix] says blah.
- @item1 [-@item2 p. 30; see also @item3] says blah.
- In a note.[^1]
- A citation group [see @item1, p. 34-35; also @item3 chap. 3].
- Another one [see
@item1 p. 34-35].
- And another one in a note.[^2]
- Citation with a suffix and locator [@item1, pp. 33, 35-37, and nowhere else].
- Citation with suffix only [@item1, and nowhere else].
- Now some modifiers.[^3]
[^1]: - @nonexistent
A citation without locators [@item3].
[^2]: - @item1 says blah.
Some citations [see @item2 chap. 3; @item3; @item1].
- @item1 [p. 30] says blah.
- @item1 [p. 30, with suffix] says blah.
- @item1 [-@item2 p. 30; see also @item3] says blah.
- In a note.[^1]
- A citation group [see @item1, p. 34-35; also @item3 chap. 3].
- Another one [see @item1 p. 34-35].
- And another one in a note.[^2]
- Citation with a suffix and locator
[@item1, pp. 33, 35-37, and nowhere else].
- Citation with suffix only [@item1, and nowhere else].
- Now some modifiers.[^3]
- With some markup [*see* @item1 p. **32**].
[^3]:
Like a citation without author: [-@item1], and now Doe with a
locator [-@item2, p. 44].
# References # References
[^1]:
A citation without locators [@item3].
[^2]:
Some citations [see @item2 chap. 3; @item3; @item1].
[^3]:
Like a citation without author: [-@item1], and now Doe with a
locator [-@item2 p. 44].

View file

@ -0,0 +1,72 @@
\documentclass{article}
\usepackage{amssymb,amsmath}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setcounter{secnumdepth}{0}
\begin{document}
\section{Pandoc with citeproc-hs}
\begin{itemize}
\item
{[}@nonexistent{]}
\item
@nonexistent
\item
\citet{item1} says blah.
\item
\citet[p.~30]{item1} says blah.
\item
\citet[p.~30, with suffix]{item1} says blah.
\item
\citeauthor{item1} \citetext{\citeyear{item1}; \citeyear[p.~30]{item2}; \citealp[see also][]{item3}}
says blah.
\item
In a note.%
\footnote{A citation without locators \citep{item3}.}
\item
A citation group
\citetext{\citealp[see][, p.~34--35]{item1}; \citealp[also][chap. 3]{item3}}.
\item
Another one \citep[see][p.~34--35]{item1}.
\item
And another one in a note.%
\footnote{Some citations
\citetext{\citealp[see][chap. 3]{item2}; \citealp{item3}; \citealp{item1}}.}
\item
Citation with a suffix and locator
\citep[, pp.~33, 35--37, and nowhere else]{item1}.
\item
Citation with suffix only \citep[, and nowhere else]{item1}.
\item
Now some modifiers.%
\footnote{Like a citation without author: \citeyearpar{item1}, and now Doe
with a locator \citeyearpar[p.~44]{item2}.}
\item
With some markup \citep[\emph{see}][p. \textbf{32}]{item1}.
\end{itemize}
\section{References}
\bibliography{biblio}
\end{document}