Revert "LaTeX reader: citation handling changes."

This reverts commit f7229b1473.
This commit is contained in:
John MacFarlane 2013-03-17 08:48:29 -07:00
parent abc3896b8e
commit cae52ecc31
7 changed files with 8 additions and 128 deletions

View file

@ -109,7 +109,6 @@ Extra-Source-Files:
tests/lalune.jpg, tests/lalune.jpg,
tests/movie.jpg, tests/movie.jpg,
tests/biblio.bib, tests/biblio.bib,
tests/biblio.mods,
tests/chicago-author-date.csl, tests/chicago-author-date.csl,
tests/ieee.csl, tests/ieee.csl,
tests/mhra.csl, tests/mhra.csl,
@ -384,7 +383,6 @@ Test-Suite test-pandoc
QuickCheck >= 2.4 && < 2.7, QuickCheck >= 2.4 && < 2.7,
HUnit >= 1.2 && < 1.3, HUnit >= 1.2 && < 1.3,
containers >= 0.1 && < 0.6, containers >= 0.1 && < 0.6,
citeproc-hs >= 0.3 && < 0.4,
ansi-terminal >= 0.5 && < 0.7 ansi-terminal >= 0.5 && < 0.7
Other-Modules: Tests.Old Other-Modules: Tests.Old
Tests.Helpers Tests.Helpers

View file

@ -1021,10 +1021,7 @@ cites mode multi = try $ do
citation :: String -> CitationMode -> Bool -> LP Inlines citation :: String -> CitationMode -> Bool -> LP Inlines
citation name mode multi = do citation name mode multi = do
(c,raw) <- withRaw $ cites mode multi (c,raw) <- withRaw $ cites mode multi
refs <- getOption readerReferences return $ cite c (rawInline "latex" $ "\\" ++ name ++ raw)
return $ if null refs
then rawInline "latex" $ "\\" ++ name ++ raw
else cite c mempty
complexNatbibCitation :: CitationMode -> LP Inlines complexNatbibCitation :: CitationMode -> LP Inlines
complexNatbibCitation mode = try $ do complexNatbibCitation mode = try $ do
@ -1043,10 +1040,8 @@ complexNatbibCitation mode = try $ do
optional $ char ';' optional $ char ';'
return $ addPrefix pref $ addSuffix suff $ cits' return $ addPrefix pref $ addSuffix suff $ cits'
(c:cits, raw) <- withRaw $ grouped parseOne (c:cits, raw) <- withRaw $ grouped parseOne
refs <- getOption readerReferences return $ cite (c{ citationMode = mode }:cits)
return $ if null refs (rawInline "latex" $ "\\citetext" ++ raw)
then rawInline "latex" $ "\\citetext" ++ raw
else cite (c{ citationMode = mode}:cits) mempty
-- tables -- tables

View file

@ -644,8 +644,7 @@ inlineToMarkdown opts (LineBreak)
| otherwise = return $ " " <> cr | otherwise = return $ " " <> cr
inlineToMarkdown _ Space = return space inlineToMarkdown _ Space = return space
inlineToMarkdown opts (Cite (c:cs) lst) inlineToMarkdown opts (Cite (c:cs) lst)
| not (null lst) = inlineListToMarkdown opts lst | not (isEnabled Ext_citations opts) = inlineListToMarkdown opts lst
-- if lst is null, citeproc wasn't run; print a pandoc markdown citation
| citationMode c == AuthorInText = do | citationMode c == AuthorInText = do
suffs <- inlineListToMarkdown opts $ citationSuffix c suffs <- inlineListToMarkdown opts $ citationSuffix c
rest <- mapM convertOne cs rest <- mapM convertOne cs

View file

@ -186,7 +186,7 @@ markdownCitationTests
++ [test "natbib" wopts "markdown-citations.txt" ++ [test "natbib" wopts "markdown-citations.txt"
"markdown-citations.txt"] "markdown-citations.txt"]
where where
ropts = ["-r", "markdown", "-w", "markdown", "--bibliography", ropts = ["-r", "markdown", "-w", "markdown-citations", "--bibliography",
"biblio.bib", "--no-wrap"] "biblio.bib", "--no-wrap"]
wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"] wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"]
styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"]) styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])

View file

@ -2,20 +2,14 @@
module Tests.Readers.LaTeX (tests) where module Tests.Readers.LaTeX (tests) where
import Text.Pandoc.Definition import Text.Pandoc.Definition
import Data.Monoid (mempty)
import Text.CSL (Reference, readBiblioFile)
import Test.Framework import Test.Framework
import Tests.Helpers import Tests.Helpers
import Tests.Arbitrary() import Tests.Arbitrary()
import Text.Pandoc.Builder import Text.Pandoc.Builder
import Text.Pandoc import Text.Pandoc
import System.IO.Unsafe (unsafePerformIO)
refs :: [Reference]
refs = unsafePerformIO $ readBiblioFile "biblio.mods"
latex :: String -> Pandoc latex :: String -> Pandoc
latex = readLaTeX def{ readerReferences = refs } latex = readLaTeX def
infix 4 =: infix 4 =:
(=:) :: ToString c (=:) :: ToString c
@ -77,7 +71,7 @@ baseCitation = Citation{ citationId = "item1"
} }
rt :: String -> Inlines rt :: String -> Inlines
rt = const mempty -- rawInline "latex" rt = rawInline "latex"
natbibCitations :: Test natbibCitations :: Test
natbibCitations = testGroup "natbib" natbibCitations = testGroup "natbib"

View file

@ -1,106 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<modsCollection xmlns="http://www.loc.gov/mods/v3">
<mods ID="item1">
<titleInfo>
<title>First Book</title>
</titleInfo>
<name type="personal">
<namePart type="given">John</namePart>
<namePart type="family">Doe</namePart>
<role>
<roleTerm authority="marcrelator" type="text">author</roleTerm>
</role>
</name>
<originInfo>
<issuance>monographic</issuance>
<dateIssued>2005</dateIssued>
<publisher>Cambridge University Press</publisher>
<place>
<placeTerm type="text">Cambridge</placeTerm>
</place>
</originInfo>
<typeOfResource>text</typeOfResource>
<genre authority="marcgt">book</genre>
<identifier type="citekey">item1</identifier>
</mods>
<mods ID="item2">
<titleInfo>
<title>Article</title>
</titleInfo>
<name type="personal">
<namePart type="given">John</namePart>
<namePart type="family">Doe</namePart>
<role>
<roleTerm authority="marcrelator" type="text">author</roleTerm>
</role>
</name>
<originInfo>
<dateIssued>2006</dateIssued>
</originInfo>
<typeOfResource>text</typeOfResource>
<relatedItem type="host">
<titleInfo>
<title>Journal of Generic Studies</title>
</titleInfo>
<originInfo>
<issuance>continuing</issuance>
</originInfo>
<genre authority="marcgt">periodical</genre>
<genre>academic journal</genre>
</relatedItem>
<identifier type="citekey">item2</identifier>
<part>
<date>2006</date>
<detail type="volume"><number>6</number></detail>
<extent unit="page">
<start>33</start>
<end>34</end>
</extent>
</part>
</mods>
<mods ID="пункт3">
<titleInfo>
<title>Why Water Is Wet</title>
</titleInfo>
<name type="personal">
<namePart type="given">John</namePart>
<namePart type="family">Doe</namePart>
<role>
<roleTerm authority="marcrelator" type="text">author</roleTerm>
</role>
</name>
<name type="personal">
<namePart type="given">Jenny</namePart>
<namePart type="family">Roe</namePart>
<role>
<roleTerm authority="marcrelator" type="text">author</roleTerm>
</role>
</name>
<originInfo>
<issuance>monographic</issuance>
<dateIssued>2007</dateIssued>
</originInfo>
<typeOfResource>text</typeOfResource>
<relatedItem type="host">
<titleInfo>
<title>Third Book</title>
</titleInfo>
<name type="personal">
<namePart type="given">Sam</namePart>
<namePart type="family">Smith</namePart>
<role>
<roleTerm authority="marcrelator" type="text">editor</roleTerm>
</role>
</name>
<originInfo>
<dateIssued>2007</dateIssued>
<publisher>Oxford University Press</publisher>
<place>
<placeTerm type="text">Oxford</placeTerm>
</place>
</originInfo>
<genre>collection</genre>
</relatedItem>
<identifier type="citekey">пункт3</identifier>
</mods>
</modsCollection>

View file

@ -260,7 +260,7 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
,HorizontalRule ,HorizontalRule
,Header 1 ("",[],[]) [Str "LaTeX"] ,Header 1 ("",[],[]) [Str "LaTeX"]
,BulletList ,BulletList
[[Para [RawInline "latex" "\\cite[22-23]{smith.1899}"]] [[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}"]]]
,[Para [RawInline "latex" "\\doublespacing"]] ,[Para [RawInline "latex" "\\doublespacing"]]
,[Para [Math InlineMath "2+2=4"]] ,[Para [Math InlineMath "2+2=4"]]
,[Para [Math InlineMath "x \\in y"]] ,[Para [Math InlineMath "x \\in y"]]