git.iko.soy/typeable/pandoc
on master help sign in
Added natbib citation tests to Tests.Readers.LaTeX.

Removed old tests/natbib-citations.latex.

commit7961208aafa35c0dd8cd4f25f7fae8e11497b075 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 29 Jan 2011, 08:47 (16 years ago) parent3a3b484
4 files changed+65−52
pandoc.cabal−1 tests/Tests/Old.hs−1 tests/Tests/Readers/LaTeX.hs+65 tests/natbib-citations.latex−50
pandoc.cabal−1
@@ -95,7 +95,6 @@ Extra-Source-Files:
9595 tests/latex-reader.latex,
9696 tests/latex-reader.native,
9797 tests/biblatex-citations.latex,
98− tests/natbib-citations.latex,
9998 tests/textile-reader.textile,
10099 tests/textile-reader.native,
101100 tests/markdown-reader-more.txt,
tests/Tests/Old.hs−1
@@ -81,7 +81,6 @@ tests = [ testGroup "markdown"
8181 , lhsReaderTest "latex+lhs"
8282 ]
8383 , latexCitationTests "biblatex"
84− , latexCitationTests "natbib"
8584 ]
8685 , testGroup "html"
8786 [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html")
tests/Tests/Readers/LaTeX.hs+65
@@ -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+
tests/natbib-citations.latexdeleted−50
@@ -1,50 +0,0 @@
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−\item
21− @nonexistent
22−\item
23− \citet{item1} says blah.
24−\item
25− \citet[p.~30]{item1} says blah.
26−\item
27− \citet[p.~30, with suffix]{item1} says blah.
28−\item
29− \citeauthor{item1} \citetext{\citeyear{item1}; \citeyear[p.~30]{item2}; \citealp[see also][]{item3}} says blah.
30−\item
31− In a note.\footnote{A citation without locators \citep{item3}.}
32−\item
33− A citation group \citetext{\citealp[see][p.~34--35]{item1}; \citealp[also][chap. 3]{item3}}.
34−\item
35− Another one \citep[see][p.~34--35]{item1}.
36−\item
37− And another one in a note.\footnote{Some citations \citetext{\citealp[see][chap. 3]{item2}; \citealp{item3}; \citealp{item1}}.}
38−\item
39− Citation with a suffix and locator \citep[pp.~33, 35--37, and nowhere else]{item1}.
40−\item
41− Citation with suffix only \citep[and nowhere else]{item1}.
42−\item
43− Now some modifiers.\footnote{Like a citation without author: \citeyearpar{item1}, and now Doe with a locator \citeyearpar[p.~44]{item2}.}
44−\item
45− With some markup \citep[\emph{see}][p. \textbf{32}]{item1}.
46−\end{itemize}
47−\renewcommand\refname{References}
48−\bibliography{biblio}
49−
50−\end{document}