git.iko.soy/typeable/pandoc
on master help sign in
Revert "LaTeX reader: citation handling changes."

This reverts commit f7229b147314042f946dfded3b441ab0fae260a0.

commitcae52ecc315a0635f81cb2547b4f268ec8a8befa authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 17 Mar 2013, 08:48 (14 years ago) parentabc3896
7 files changed+8−128
pandoc.cabal−2 src/Text/Pandoc/Readers/LaTeX.hs+3−8 src/Text/Pandoc/Writers/Markdown.hs+1−2 tests/Tests/Old.hs+1−1 tests/Tests/Readers/LaTeX.hs+2−8 tests/biblio.mods−106 tests/latex-reader.native+1−1
pandoc.cabal−2
@@ -109,7 +109,6 @@ Extra-Source-Files:
109109 tests/lalune.jpg,
110110 tests/movie.jpg,
111111 tests/biblio.bib,
112− tests/biblio.mods,
113112 tests/chicago-author-date.csl,
114113 tests/ieee.csl,
115114 tests/mhra.csl,
@@ -384,7 +383,6 @@ Test-Suite test-pandoc
384383 QuickCheck >= 2.4 && < 2.7,
385384 HUnit >= 1.2 && < 1.3,
386385 containers >= 0.1 && < 0.6,
387− citeproc-hs >= 0.3 && < 0.4,
388386 ansi-terminal >= 0.5 && < 0.7
389387 Other-Modules: Tests.Old
390388 Tests.Helpers
src/Text/Pandoc/Readers/LaTeX.hs+3−8
@@ -1021,10 +1021,7 @@ cites mode multi = try $ do
10211021citation :: String -> CitationMode -> Bool -> LP Inlines
10221022citation name mode multi = do
10231023 (c,raw) <- withRaw $ cites mode multi
1024− refs <- getOption readerReferences
1025− return $ if null refs
1026− then rawInline "latex" $ "\\" ++ name ++ raw
1027− else cite c mempty
1024+ return $ cite c (rawInline "latex" $ "\\" ++ name ++ raw)
10281025
10291026complexNatbibCitation :: CitationMode -> LP Inlines
10301027complexNatbibCitation mode = try $ do
@@ -1043,10 +1040,8 @@ complexNatbibCitation mode = try $ do
10431040 optional $ char ';'
10441041 return $ addPrefix pref $ addSuffix suff $ cits'
10451042 (c:cits, raw) <- withRaw $ grouped parseOne
1046− refs <- getOption readerReferences
1047− return $ if null refs
1048− then rawInline "latex" $ "\\citetext" ++ raw
1049− else cite (c{ citationMode = mode}:cits) mempty
1043+ return $ cite (c{ citationMode = mode }:cits)
1044+ (rawInline "latex" $ "\\citetext" ++ raw)
10501045
10511046-- tables
10521047
src/Text/Pandoc/Writers/Markdown.hs+1−2
@@ -644,8 +644,7 @@ inlineToMarkdown opts (LineBreak)
644644 | otherwise = return $ " " <> cr
645645inlineToMarkdown _ Space = return space
646646inlineToMarkdown opts (Cite (c:cs) lst)
647− | not (null lst) = inlineListToMarkdown opts lst
648− -- if lst is null, citeproc wasn't run; print a pandoc markdown citation
647+ | not (isEnabled Ext_citations opts) = inlineListToMarkdown opts lst
649648 | citationMode c == AuthorInText = do
650649 suffs <- inlineListToMarkdown opts $ citationSuffix c
651650 rest <- mapM convertOne cs
tests/Tests/Old.hs+1−1
@@ -186,7 +186,7 @@ markdownCitationTests
186186 ++ [test "natbib" wopts "markdown-citations.txt"
187187 "markdown-citations.txt"]
188188 where
189− ropts = ["-r", "markdown", "-w", "markdown", "--bibliography",
189+ ropts = ["-r", "markdown", "-w", "markdown-citations", "--bibliography",
190190 "biblio.bib", "--no-wrap"]
191191 wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"]
192192 styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
tests/Tests/Readers/LaTeX.hs+2−8
@@ -2,20 +2,14 @@
22module Tests.Readers.LaTeX (tests) where
33
44import Text.Pandoc.Definition
5−import Data.Monoid (mempty)
6−import Text.CSL (Reference, readBiblioFile)
75import Test.Framework
86import Tests.Helpers
97import Tests.Arbitrary()
108import Text.Pandoc.Builder
119import Text.Pandoc
12−import System.IO.Unsafe (unsafePerformIO)
13−
14−refs :: [Reference]
15−refs = unsafePerformIO $ readBiblioFile "biblio.mods"
1610
1711latex :: String -> Pandoc
18−latex = readLaTeX def{ readerReferences = refs }
12+latex = readLaTeX def
1913
2014infix 4 =:
2115(=:) :: ToString c
@@ -77,7 +71,7 @@ baseCitation = Citation{ citationId = "item1"
7771 }
7872
7973rt :: String -> Inlines
80−rt = const mempty -- rawInline "latex"
74+rt = rawInline "latex"
8175
8276natbibCitations :: Test
8377natbibCitations = testGroup "natbib"
tests/biblio.modsdeleted−106
@@ -1,106 +0,0 @@
1−<?xml version="1.0" encoding="UTF-8"?>
2−<modsCollection xmlns="http://www.loc.gov/mods/v3">
3−<mods ID="item1">
4− <titleInfo>
5− <title>First Book</title>
6− </titleInfo>
7− <name type="personal">
8− <namePart type="given">John</namePart>
9− <namePart type="family">Doe</namePart>
10− <role>
11− <roleTerm authority="marcrelator" type="text">author</roleTerm>
12− </role>
13− </name>
14− <originInfo>
15− <issuance>monographic</issuance>
16− <dateIssued>2005</dateIssued>
17− <publisher>Cambridge University Press</publisher>
18− <place>
19− <placeTerm type="text">Cambridge</placeTerm>
20− </place>
21− </originInfo>
22− <typeOfResource>text</typeOfResource>
23− <genre authority="marcgt">book</genre>
24− <identifier type="citekey">item1</identifier>
25−</mods>
26−<mods ID="item2">
27− <titleInfo>
28− <title>Article</title>
29− </titleInfo>
30− <name type="personal">
31− <namePart type="given">John</namePart>
32− <namePart type="family">Doe</namePart>
33− <role>
34− <roleTerm authority="marcrelator" type="text">author</roleTerm>
35− </role>
36− </name>
37− <originInfo>
38− <dateIssued>2006</dateIssued>
39− </originInfo>
40− <typeOfResource>text</typeOfResource>
41− <relatedItem type="host">
42− <titleInfo>
43− <title>Journal of Generic Studies</title>
44− </titleInfo>
45− <originInfo>
46− <issuance>continuing</issuance>
47− </originInfo>
48− <genre authority="marcgt">periodical</genre>
49− <genre>academic journal</genre>
50− </relatedItem>
51− <identifier type="citekey">item2</identifier>
52− <part>
53− <date>2006</date>
54− <detail type="volume"><number>6</number></detail>
55− <extent unit="page">
56− <start>33</start>
57− <end>34</end>
58− </extent>
59− </part>
60−</mods>
61−<mods ID="пункт3">
62− <titleInfo>
63− <title>Why Water Is Wet</title>
64− </titleInfo>
65− <name type="personal">
66− <namePart type="given">John</namePart>
67− <namePart type="family">Doe</namePart>
68− <role>
69− <roleTerm authority="marcrelator" type="text">author</roleTerm>
70− </role>
71− </name>
72− <name type="personal">
73− <namePart type="given">Jenny</namePart>
74− <namePart type="family">Roe</namePart>
75− <role>
76− <roleTerm authority="marcrelator" type="text">author</roleTerm>
77− </role>
78− </name>
79− <originInfo>
80− <issuance>monographic</issuance>
81− <dateIssued>2007</dateIssued>
82− </originInfo>
83− <typeOfResource>text</typeOfResource>
84− <relatedItem type="host">
85− <titleInfo>
86− <title>Third Book</title>
87− </titleInfo>
88− <name type="personal">
89− <namePart type="given">Sam</namePart>
90− <namePart type="family">Smith</namePart>
91− <role>
92− <roleTerm authority="marcrelator" type="text">editor</roleTerm>
93− </role>
94− </name>
95− <originInfo>
96− <dateIssued>2007</dateIssued>
97− <publisher>Oxford University Press</publisher>
98− <place>
99− <placeTerm type="text">Oxford</placeTerm>
100− </place>
101− </originInfo>
102− <genre>collection</genre>
103− </relatedItem>
104− <identifier type="citekey">пункт3</identifier>
105−</mods>
106−</modsCollection>
tests/latex-reader.native+1−1
@@ -260,7 +260,7 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
260260,HorizontalRule
261261,Header 1 ("",[],[]) [Str "LaTeX"]
262262,BulletList
263− [[Para [RawInline "latex" "\\cite[22-23]{smith.1899}"]]
263+ [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str ",",Space,Str "22-23"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [RawInline "latex" "\\cite[22-23]{smith.1899}"]]]
264264 ,[Para [RawInline "latex" "\\doublespacing"]]
265265 ,[Para [Math InlineMath "2+2=4"]]
266266 ,[Para [Math InlineMath "x \\in y"]]