From d8c9b0c6f704d1ca526c05cffdf87d050243edea Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 29 Jan 2011 09:01:30 -0800 Subject: Added biblatex citation tests to Tests.Readers.LaTeX. Removed old biblatex-citations.latex. --- tests/Tests/Old.hs | 20 +------------------ tests/Tests/Readers/LaTeX.hs | 47 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 21 deletions(-) (limited to 'tests/Tests') diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs index 7321308de..cb1417ffa 100644 --- a/tests/Tests/Old.hs +++ b/tests/Tests/Old.hs @@ -10,7 +10,7 @@ import System.FilePath ( (), (<.>) ) import System.Directory import System.Exit import Data.Algorithm.Diff -import Text.Pandoc.Shared ( substitute, normalize, defaultWriterOptions ) +import Text.Pandoc.Shared ( normalize, defaultWriterOptions ) import Text.Pandoc.Writers.Native ( writeNative ) import Text.Pandoc.Readers.Native ( readNative ) import Text.Pandoc.Highlighting ( languages ) @@ -80,7 +80,6 @@ tests = [ testGroup "markdown" "latex-reader.latex" "latex-reader.native" , lhsReaderTest "latex+lhs" ] - , latexCitationTests "biblatex" ] , testGroup "html" [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html") @@ -133,23 +132,6 @@ lhsReaderTest format = ("lhs-test" <.> format) "lhs-test.native" where normalizer = writeNative defaultWriterOptions . normalize . readNative -latexCitationTests :: String -> Test -latexCitationTests n - = testGroup (n ++ " citations") - [ t ("latex reader (" ++ n ++ " citations)") - (["-r", "latex", "-w", "markdown", "-s", "--no-wrap"] ++ o) - f "markdown-citations.txt" - , t ("latex writer (" ++ n ++ " citations)") - (["-r", "markdown", "-w", "latex", "-s", "--no-wrap"] ++ o) - "markdown-citations.txt" f - ] - where - o = ["--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl", - "--natbib", "--" ++ n] - f = n ++ "-citations.latex" - normalizer = substitute "\160" " " . substitute "\8211" "-" - t = testWithNormalize normalizer - writerTests :: String -> [Test] writerTests format = [ test "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format) diff --git a/tests/Tests/Readers/LaTeX.hs b/tests/Tests/Readers/LaTeX.hs index f230ef5bf..7ea4c73ee 100644 --- a/tests/Tests/Readers/LaTeX.hs +++ b/tests/Tests/Readers/LaTeX.hs @@ -104,6 +104,49 @@ natbibCitations = testGroup "natbib" biblatexCitations :: Test biblatexCitations = testGroup "biblatex" - [ + [ "textcite" =: "\\textcite{item1}" + =?> para (cite [baseCitation] empty) + , "suffix" =: "\\textcite[p.~30]{item1}" + =?> para + (cite [baseCitation{ citationSuffix = toList $ text "p.\160\&30" }] empty) + , "suffix long" =: "\\textcite[p.~30, with suffix]{item1}" + =?> para (cite [baseCitation{ citationSuffix = + toList $ text "p.\160\&30, with suffix" }] empty) + , "multiple" =: "\\textcites{item1}[p.~30]{item2}[see also][]{item3}" + =?> para (cite [baseCitation{ citationMode = AuthorInText } + ,baseCitation{ citationMode = NormalCitation + , citationSuffix = [Str "p.\160\&30"] + , citationId = "item2" } + ,baseCitation{ citationId = "item3" + , citationPrefix = [Str "see",Space,Str "also"] + , citationMode = NormalCitation } + ] empty) + , "group" =: "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}" + =?> para (cite [baseCitation{ citationMode = NormalCitation + , citationPrefix = [Str "see"] + , citationSuffix = [Str "p.\160\&34",EnDash,Str "35"] } + ,baseCitation{ citationMode = NormalCitation + , citationId = "item3" + , citationPrefix = [Str "also"] + , citationSuffix = [Str "chap.",Space,Str "3"] } + ] empty) + , "suffix and locator" =: "\\autocite[pp.~33, 35--37, and nowhere else]{item1}" + =?> para (cite [baseCitation{ citationMode = NormalCitation + , citationSuffix = [Str "pp.\160\&33,",Space,Str "35",EnDash,Str "37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] empty) + , "suffix only" =: "\\autocite[and nowhere else]{item1}" + =?> para (cite [baseCitation{ citationMode = NormalCitation + , citationSuffix = toList $ text "and nowhere else" }] empty) + , "no author" =: "\\autocite*{item1}, and now Doe with a locator \\autocite*[p.~44]{item2}" + =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] empty +++ + text ", and now Doe with a locator " +++ + cite [baseCitation{ citationMode = SuppressAuthor + , citationSuffix = [Str "p.\160\&44"] + , citationId = "item2" }] empty) + , "markup" =: "\\autocite[\\emph{see}][p. \\textbf{32}]{item1}" + =?> para (cite [baseCitation{ citationMode = NormalCitation + , citationPrefix = [Emph [Str "see"]] + , citationSuffix = [Str "p.",Space, + Strong [Str "32"]] }] empty) + , "parencite" =: "\\parencite{item1}" + =?> para (cite [baseCitation{ citationMode = NormalCitation }] empty) ] - -- cgit v1.2.3