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

Removed old biblatex-citations.latex.

commitd8c9b0c6f704d1ca526c05cffdf87d050243edea authorJohn MacFarlane <jgm@berkeley.edu> dateSat 29 Jan 2011, 09:01 (16 years ago) parent7961208
4 files changed+46−71
pandoc.cabal−1 tests/Tests/Old.hs+1−19 tests/Tests/Readers/LaTeX.hs+45−2 tests/biblatex-citations.latex−49
pandoc.cabal−1
@@ -94,7 +94,6 @@ Extra-Source-Files:
9494 tests/mhra.csl,
9595 tests/latex-reader.latex,
9696 tests/latex-reader.native,
97− tests/biblatex-citations.latex,
9897 tests/textile-reader.textile,
9998 tests/textile-reader.native,
10099 tests/markdown-reader-more.txt,
tests/Tests/Old.hs+1−19
@@ -10,7 +10,7 @@ import System.FilePath ( (</>), (<.>) )
1010import System.Directory
1111import System.Exit
1212import Data.Algorithm.Diff
13−import Text.Pandoc.Shared ( substitute, normalize, defaultWriterOptions )
13+import Text.Pandoc.Shared ( normalize, defaultWriterOptions )
1414import Text.Pandoc.Writers.Native ( writeNative )
1515import Text.Pandoc.Readers.Native ( readNative )
1616import Text.Pandoc.Highlighting ( languages )
@@ -80,7 +80,6 @@ tests = [ testGroup "markdown"
8080 "latex-reader.latex" "latex-reader.native"
8181 , lhsReaderTest "latex+lhs"
8282 ]
83− , latexCitationTests "biblatex"
8483 ]
8584 , testGroup "html"
8685 [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html")
@@ -133,23 +132,6 @@ lhsReaderTest format =
133132 ("lhs-test" <.> format) "lhs-test.native"
134133 where normalizer = writeNative defaultWriterOptions . normalize . readNative
135134
136−latexCitationTests :: String -> Test
137−latexCitationTests n
138− = testGroup (n ++ " citations")
139− [ t ("latex reader (" ++ n ++ " citations)")
140− (["-r", "latex", "-w", "markdown", "-s", "--no-wrap"] ++ o)
141− f "markdown-citations.txt"
142− , t ("latex writer (" ++ n ++ " citations)")
143− (["-r", "markdown", "-w", "latex", "-s", "--no-wrap"] ++ o)
144− "markdown-citations.txt" f
145− ]
146− where
147− o = ["--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl",
148− "--natbib", "--" ++ n]
149− f = n ++ "-citations.latex"
150− normalizer = substitute "\160" " " . substitute "\8211" "-"
151− t = testWithNormalize normalizer
152−
153135writerTests :: String -> [Test]
154136writerTests format
155137 = [ test "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
tests/Tests/Readers/LaTeX.hs+45−2
@@ -104,6 +104,49 @@ natbibCitations = testGroup "natbib"
104104
105105biblatexCitations :: Test
106106biblatexCitations = testGroup "biblatex"
107− [
107+ [ "textcite" =: "\\textcite{item1}"
108+ =?> para (cite [baseCitation] empty)
109+ , "suffix" =: "\\textcite[p.~30]{item1}"
110+ =?> para
111+ (cite [baseCitation{ citationSuffix = toList $ text "p.\160\&30" }] empty)
112+ , "suffix long" =: "\\textcite[p.~30, with suffix]{item1}"
113+ =?> para (cite [baseCitation{ citationSuffix =
114+ toList $ text "p.\160\&30, with suffix" }] empty)
115+ , "multiple" =: "\\textcites{item1}[p.~30]{item2}[see also][]{item3}"
116+ =?> para (cite [baseCitation{ citationMode = AuthorInText }
117+ ,baseCitation{ citationMode = NormalCitation
118+ , citationSuffix = [Str "p.\160\&30"]
119+ , citationId = "item2" }
120+ ,baseCitation{ citationId = "item3"
121+ , citationPrefix = [Str "see",Space,Str "also"]
122+ , citationMode = NormalCitation }
123+ ] empty)
124+ , "group" =: "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}"
125+ =?> para (cite [baseCitation{ citationMode = NormalCitation
126+ , citationPrefix = [Str "see"]
127+ , citationSuffix = [Str "p.\160\&34",EnDash,Str "35"] }
128+ ,baseCitation{ citationMode = NormalCitation
129+ , citationId = "item3"
130+ , citationPrefix = [Str "also"]
131+ , citationSuffix = [Str "chap.",Space,Str "3"] }
132+ ] empty)
133+ , "suffix and locator" =: "\\autocite[pp.~33, 35--37, and nowhere else]{item1}"
134+ =?> para (cite [baseCitation{ citationMode = NormalCitation
135+ , citationSuffix = [Str "pp.\160\&33,",Space,Str "35",EnDash,Str "37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] empty)
136+ , "suffix only" =: "\\autocite[and nowhere else]{item1}"
137+ =?> para (cite [baseCitation{ citationMode = NormalCitation
138+ , citationSuffix = toList $ text "and nowhere else" }] empty)
139+ , "no author" =: "\\autocite*{item1}, and now Doe with a locator \\autocite*[p.~44]{item2}"
140+ =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] empty +++
141+ text ", and now Doe with a locator " +++
142+ cite [baseCitation{ citationMode = SuppressAuthor
143+ , citationSuffix = [Str "p.\160\&44"]
144+ , citationId = "item2" }] empty)
145+ , "markup" =: "\\autocite[\\emph{see}][p. \\textbf{32}]{item1}"
146+ =?> para (cite [baseCitation{ citationMode = NormalCitation
147+ , citationPrefix = [Emph [Str "see"]]
148+ , citationSuffix = [Str "p.",Space,
149+ Strong [Str "32"]] }] empty)
150+ , "parencite" =: "\\parencite{item1}"
151+ =?> para (cite [baseCitation{ citationMode = NormalCitation }] empty)
108152 ]
109−
tests/biblatex-citations.latexdeleted−49
@@ -1,49 +0,0 @@
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−\item
21− @nonexistent
22−\item
23− \textcite{item1} says blah.
24−\item
25− \textcite[p.~30]{item1} says blah.
26−\item
27− \textcite[p.~30, with suffix]{item1} says blah.
28−\item
29− \textcites{item1}[p.~30]{item2}[see also][]{item3} says blah.
30−\item
31− In a note.\footnote{A citation without locators \autocite{item3}.}
32−\item
33− A citation group \autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}.
34−\item
35− Another one \autocite[see][p.~34--35]{item1}.
36−\item
37− And another one in a note.\footnote{Some citations \autocites[see][chap. 3]{item2}{item3}{item1}.}
38−\item
39− Citation with a suffix and locator \autocite[pp.~33, 35--37, and nowhere else]{item1}.
40−\item
41− Citation with suffix only \autocite[and nowhere else]{item1}.
42−\item
43− Now some modifiers.\footnote{Like a citation without author: \autocite*{item1}, and now Doe with a locator \autocite*[p.~44]{item2}.}
44−\item
45− With some markup \autocite[\emph{see}][p. \textbf{32}]{item1}.
46−\end{itemize}
47−\printbibliography[title=References]
48−
49−\end{document}