git.iko.soy/typeable/pandoc
on master help sign in
Revert "LaTeX reader: citation handling changes."
cae52ecJohn MacFarlane
pandoc.cabal−2
@@ -109,7 +109,6 @@ Extra-Source-Files:
109 tests/lalune.jpg,
109 tests/lalune.jpg,
110 tests/movie.jpg,
110 tests/movie.jpg,
111 tests/biblio.bib,
111 tests/biblio.bib,
112− tests/biblio.mods,
113 tests/chicago-author-date.csl,
112 tests/chicago-author-date.csl,
114 tests/ieee.csl,
113 tests/ieee.csl,
115 tests/mhra.csl,
114 tests/mhra.csl,
@@ -384,7 +383,6 @@ Test-Suite test-pandoc
384 QuickCheck >= 2.4 && < 2.7,
383 QuickCheck >= 2.4 && < 2.7,
385 HUnit >= 1.2 && < 1.3,
384 HUnit >= 1.2 && < 1.3,
386 containers >= 0.1 && < 0.6,
385 containers >= 0.1 && < 0.6,
387− citeproc-hs >= 0.3 && < 0.4,
388 ansi-terminal >= 0.5 && < 0.7
386 ansi-terminal >= 0.5 && < 0.7
389 Other-Modules: Tests.Old
387 Other-Modules: Tests.Old
390 Tests.Helpers
388 Tests.Helpers
src/Text/Pandoc/Readers/LaTeX.hs+3−8
@@ -1021,10 +1021,7 @@ cites mode multi = try $ do
1021citation :: String -> CitationMode -> Bool -> LP Inlines
1021citation :: String -> CitationMode -> Bool -> LP Inlines
1022citation name mode multi = do
1022citation name mode multi = do
1023 (c,raw) <- withRaw $ cites mode multi
1023 (c,raw) <- withRaw $ cites mode multi
1024− refs <- getOption readerReferences
1025− return $ if null refs
1026− then rawInline "latex" $ "\\" ++ name ++ raw
1024+ return $ cite c (rawInline "latex" $ "\\" ++ name ++ raw)
1027− else cite c mempty
1028
1025
1029complexNatbibCitation :: CitationMode -> LP Inlines
1026complexNatbibCitation :: CitationMode -> LP Inlines
1030complexNatbibCitation mode = try $ do
1027complexNatbibCitation mode = try $ do
@@ -1043,10 +1040,8 @@ complexNatbibCitation mode = try $ do
1043 optional $ char ';'
1040 optional $ char ';'
1044 return $ addPrefix pref $ addSuffix suff $ cits'
1041 return $ addPrefix pref $ addSuffix suff $ cits'
1045 (c:cits, raw) <- withRaw $ grouped parseOne
1042 (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)
1050
1045
1051-- tables
1046-- tables
1052
1047
src/Text/Pandoc/Writers/Markdown.hs+1−2
@@ -644,8 +644,7 @@ inlineToMarkdown opts (LineBreak)
644 | otherwise = return $ " " <> cr
644 | otherwise = return $ " " <> cr
645inlineToMarkdown _ Space = return space
645inlineToMarkdown _ Space = return space
646inlineToMarkdown opts (Cite (c:cs) lst)
646inlineToMarkdown opts (Cite (c:cs) lst)
647− | not (null lst) = inlineListToMarkdown opts lst
647+ | not (isEnabled Ext_citations opts) = inlineListToMarkdown opts lst
648− -- if lst is null, citeproc wasn't run; print a pandoc markdown citation
649 | citationMode c == AuthorInText = do
648 | citationMode c == AuthorInText = do
650 suffs <- inlineListToMarkdown opts $ citationSuffix c
649 suffs <- inlineListToMarkdown opts $ citationSuffix c
651 rest <- mapM convertOne cs
650 rest <- mapM convertOne cs
tests/Tests/Old.hs+1−1
@@ -186,7 +186,7 @@ markdownCitationTests
186 ++ [test "natbib" wopts "markdown-citations.txt"
186 ++ [test "natbib" wopts "markdown-citations.txt"
187 "markdown-citations.txt"]
187 "markdown-citations.txt"]
188 where
188 where
189− ropts = ["-r", "markdown", "-w", "markdown", "--bibliography",
189+ ropts = ["-r", "markdown", "-w", "markdown-citations", "--bibliography",
190 "biblio.bib", "--no-wrap"]
190 "biblio.bib", "--no-wrap"]
191 wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"]
191 wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"]
192 styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
192 styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
tests/Tests/Readers/LaTeX.hs+2−8
@@ -2,20 +2,14 @@
2module Tests.Readers.LaTeX (tests) where
2module Tests.Readers.LaTeX (tests) where
3
3
4import Text.Pandoc.Definition
4import Text.Pandoc.Definition
5−import Data.Monoid (mempty)
6−import Text.CSL (Reference, readBiblioFile)
7import Test.Framework
5import Test.Framework
8import Tests.Helpers
6import Tests.Helpers
9import Tests.Arbitrary()
7import Tests.Arbitrary()
10import Text.Pandoc.Builder
8import Text.Pandoc.Builder
11import Text.Pandoc
9import Text.Pandoc
12−import System.IO.Unsafe (unsafePerformIO)
13−
14−refs :: [Reference]
15−refs = unsafePerformIO $ readBiblioFile "biblio.mods"
16
10
17latex :: String -> Pandoc
11latex :: String -> Pandoc
18−latex = readLaTeX def{ readerReferences = refs }
12+latex = readLaTeX def
19
13
20infix 4 =:
14infix 4 =:
21(=:) :: ToString c
15(=:) :: ToString c
@@ -77,7 +71,7 @@ baseCitation = Citation{ citationId = "item1"
77 }
71 }
78
72
79rt :: String -> Inlines
73rt :: String -> Inlines
80−rt = const mempty -- rawInline "latex"
74+rt = rawInline "latex"
81
75
82natbibCitations :: Test
76natbibCitations :: Test
83natbibCitations = testGroup "natbib"
77natbibCitations = 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
260,HorizontalRule
260,HorizontalRule
261,Header 1 ("",[],[]) [Str "LaTeX"]
261,Header 1 ("",[],[]) [Str "LaTeX"]
262,BulletList
262,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}"]]]
264 ,[Para [RawInline "latex" "\\doublespacing"]]
264 ,[Para [RawInline "latex" "\\doublespacing"]]
265 ,[Para [Math InlineMath "2+2=4"]]
265 ,[Para [Math InlineMath "2+2=4"]]
266 ,[Para [Math InlineMath "x \\in y"]]
266 ,[Para [Math InlineMath "x \\in y"]]