pandoc-citeproc 0.10.2.2 → 0.10.3
raw patch · 17 files changed
+195/−249 lines, 17 filesdep ~aesondep ~pandocPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, pandoc
API changes (from Hackage documentation)
Files
- changelog +13/−0
- pandoc-citeproc.cabal +5/−5
- src/Text/CSL/Eval/Names.hs +1/−0
- src/Text/CSL/Input/Bibtex.hs +43/−11
- src/Text/CSL/Pandoc.hs +14/−9
- stack.yaml +3/−4
- tests/biblio2yaml/book-averroes.biblatex +1/−2
- tests/biblio2yaml/edtf-date.biblatex +98/−0
- tests/biblio2yaml/incollection.biblatex +2/−2
- tests/biblio2yaml/itzhaki.biblatex +1/−2
- tests/biblio2yaml/malinowski.biblatex +1/−1
- tests/biblio2yaml/murray.biblatex +1/−2
- tests/biblio2yaml/pines.biblatex +2/−2
- tests/biblio2yaml/test-case-conversion.biblatex +3/−3
- tests/biblio2yaml/textnormal.biblatex +1/−1
- tests/isme.csl +0/−204
- tests/test-pandoc-citeproc.hs +6/−1
changelog view
@@ -1,3 +1,16 @@+pandoc-citeproc (0.10.3)++ * Update to work with pandoc 1.19 (including writerStandalone API change).+ * Updated test case to use bracketed_spans. Note: this means that tests+ will fail unless pandoc 1.19 is used.+ * Fixed pluralization with label for issue (#267).+ * Factored out `comb` in Text.CSL.Pandoc.+ * Make it clearer when errors concern CSL parsing (#219).+ Errors in CSL parsing now point to the CSL file specifically.+ We convert any error thrown in CSL parsing into an XMLException+ (from xml-conduit), so the file path will be shown.+ * Handle EDTF dates in bibtex bibliographies (#240).+ pandoc-citeproc (0.10.2.2) * Fix overlapping instances with aeson-1.0.2.1 (#263).
pandoc-citeproc.cabal view
@@ -1,5 +1,5 @@ name: pandoc-citeproc-version: 0.10.2.2+version: 0.10.3 cabal-version: >= 1.12 synopsis: Supports using pandoc with citeproc @@ -97,7 +97,7 @@ build-depends: containers, directory, mtl, bytestring, filepath, pandoc-types >= 1.16 && < 1.18,- pandoc >= 1.16 && < 1.19,+ pandoc >= 1.16 && < 1.20, tagsoup, aeson >= 0.7 && < 1.1, text, vector, xml-conduit >= 1.2 && < 1.5,@@ -142,7 +142,7 @@ ghc-prof-options: -fprof-auto-exported -rtsopts build-depends: base >= 4, pandoc-citeproc, pandoc-types >= 1.16 && < 1.18,- pandoc >= 1.16 && < 1.19,+ pandoc >= 1.16 && < 1.20, aeson, aeson-pretty >= 0.8, yaml, bytestring, syb, attoparsec, text, filepath@@ -164,7 +164,7 @@ Buildable: False build-depends: base >= 4, aeson, directory, text, pandoc-types >= 1.16 && < 1.18,- pandoc >= 1.16 && < 1.19,+ pandoc >= 1.16 && < 1.20, filepath, bytestring, pandoc-citeproc, process, temporary >= 1.1, yaml >= 0.8.8.7, containers >= 0.4, vector >= 0.10@@ -178,7 +178,7 @@ Hs-Source-Dirs: tests, prelude build-depends: base >= 4, aeson, directory, text, pandoc-types >= 1.16 && < 1.18,- pandoc >= 1.16 && < 1.19, filepath,+ pandoc >= 1.16 && < 1.20, filepath, bytestring, pandoc-citeproc, process, temporary >= 1.1, yaml >= 0.8.8.7 default-language: Haskell2010
src/Text/CSL/Eval/Names.hs view
@@ -350,6 +350,7 @@ form (\fm' -> return . flip OLoc emptyFormatting . output fm') id l (isRange v) | "page" <- s = checkPlural | "volume" <- s = checkPlural+ | "issue" <- s = checkPlural | "ibid" <- s = format s p | isRole s = do a <- getAgents' (if s == "editortranslator" then "editor"
src/Text/CSL/Input/Bibtex.hs view
@@ -33,7 +33,8 @@ import System.Environment (getEnvironment) import Text.CSL.Reference import Text.CSL.Style (Formatted(..), Locale(..), CslTerm(..), Agent(..))-import Text.CSL.Util (trim, onBlocks, unTitlecase, protectCase, splitStrWhen)+import Text.CSL.Util (trim, onBlocks, unTitlecase, protectCase, splitStrWhen,+ safeRead) import Text.CSL.Parser (parseLocale) import qualified Text.Pandoc.Walk as Walk import qualified Text.Pandoc.UTF8 as UTF8@@ -903,22 +904,53 @@ getDates f = getRawField f >>= parseDates parseDates :: Monad m => String-> m [RefDate]-parseDates = mapM parseDate . splitWhen (== '/')+parseDates s+ | '/' `elem` s = mapM parseDate . splitWhen (== '/') $ s+ -- 199u EDTF format for a range:+ | 'u' `elem` s = let s1 = map (\c -> if c == 'u' then '0' else c) s+ s2 = map (\c -> if c == 'u' then '9' else c) s+ in mapM parseDate [s1, s2]+ | otherwise = mapM parseDate [s] parseDate :: Monad m => String -> m RefDate+-- EDTF format for year of more than 4 digits, starts with 'y':+parseDate ('y':xs) = parseDate xs+parseDate "open" = return RefDate { year = mempty,+ month = mempty, season = mempty, day = mempty,+ other = mempty, circa = False }+parseDate "unknown" = return RefDate { year = mempty,+ month = mempty, season = mempty, day = mempty,+ other = mempty, circa = False } parseDate s = do+ let circa' = '~' `elem` s let (year', month', day') =- case splitWhen (== '-') s of- [y] -> (y, mempty, mempty)- [y,m] -> (y, m, mempty)- [y,m,d] -> (y, m, d)- _ -> (mempty, mempty, mempty)- return RefDate { year = Literal $ dropWhile (=='0') year'- , month = Literal $ dropWhile (=='0') month'- , season = mempty+ case splitWhen (== '-') $ filter (`notElem` "~?")+ -- drop time component:+ $ takeWhile (/='T') s of+ -- initial - is negative year:+ ["",y] -> ('-':y, mempty, mempty)+ ["",y,m] -> ('-':y, m, mempty)+ ["",y,m,d] -> ('-':y, m, d)+ [y] -> (y, mempty, mempty)+ [y,m] -> (y, m, mempty)+ [y,m,d] -> (y, m, d)+ _ -> (mempty, mempty, mempty)+ let year'' = case safeRead year' of+ -- EDTF 0 == CSL JSON -1 (1 BCE)+ Just n | n <= 0 -> show (n - 1)+ _ -> year'+ let (season'', month'') = case month' of+ "21" -> ("1","")+ "22" -> ("2","")+ "23" -> ("3","")+ "24" -> ("4","")+ _ -> ("", month')+ return RefDate { year = Literal $ dropWhile (=='0') year''+ , month = Literal $ dropWhile (=='0') month''+ , season = Literal season'' , day = Literal $ dropWhile (=='0') day' , other = mempty- , circa = False+ , circa = circa' } isNumber :: String -> Bool
src/Text/CSL/Pandoc.hs view
@@ -33,6 +33,7 @@ import Text.CSL.Util (findFile, splitStrWhen, tr', parseRomanNumeral, trim) import System.IO.Error (isDoesNotExistError) import Data.Maybe (fromMaybe)+import Text.XML (XMLException(..)) -- | Process a 'Pandoc' document by adding citations formatted -- according to a CSL style. Add a bibliography (if one is called@@ -167,7 +168,9 @@ else getDefaultCSL Nothing -> getDefaultCSL csl <- case cslfile of- Just f | not (null f) -> readCSLFile mbLocale f+ Just f | not (null f) -> E.catch+ (readCSLFile mbLocale f) $ \e ->+ E.throwIO (InvalidXMLFile f e) _ -> do -- get default CSL: look first in ~/.csl, and take -- from distribution if not found@@ -313,18 +316,20 @@ go' (Cite cs [Note [Para xs]] : ys) = comb (\zs -> [Cite cs zs]) xs ys go' (Note [Para xs] : ys) = comb id xs ys go' xs = xs- removeLeadingPunct (Str [c] : s : xs)- | isSpacy s && (c == ',' || c == '.' || c == ':') = xs- removeLeadingPunct xs = xs- comb f xs ys =- let xs' = if startWithPunct ys && endWithPunct True xs- then initInline $ removeLeadingPunct xs- else removeLeadingPunct xs- in f xs' ++ ys sanitize :: [Block] -> [Block] sanitize [Para xs] = [Para $ toCapital xs ++ if endWithPunct False xs then [Space] else []] sanitize bs = bs++comb :: ([Inline] -> [Inline]) -> [Inline] -> [Inline] -> [Inline]+comb f xs ys =+ let xs' = if startWithPunct ys && endWithPunct True xs+ then initInline $ removeLeadingPunct xs+ else removeLeadingPunct xs+ removeLeadingPunct (Str [c] : s : xs)+ | isSpacy s && (c == ',' || c == '.' || c == ':') = xs+ removeLeadingPunct xs = xs+ in f xs' ++ ys -- | Retrieve all citations from a 'Pandoc' docuument. To be used with -- 'query'.
stack.yaml view
@@ -9,10 +9,9 @@ - '.' - location: git: https://github.com/jgm/pandoc.git- commit: bd71569483e8b471bcd94203e6f7be6b47b65280+ commit: fb8a2540bdb91eee0ecf620b4e9d7acf3d78042f extra-deps:-- texmath-0.8.6.6 - doctemplates-0.1.0.2 - pandoc-types-1.17.0.4-- aeson-1.0.2.1-resolver: lts-7.5+- texmath-0.9+resolver: lts-7.9
tests/biblio2yaml/book-averroes.biblatex view
@@ -66,8 +66,7 @@ title: The epistle on the possibility of conjunction with the active intellect by Ibn Rushd with the commentary of Moses Narboni title-short: Possibility of conjunction- collection-title: '<span class="nocase">Moreshet: Studies in Jewish History, Literature- and Thought</span>'+ collection-title: '[Moreshet: Studies in Jewish History, Literature and Thought]{.nocase}' collection-number: '7' publisher: Jewish Theological Seminary of America publisher-place: New York
+ tests/biblio2yaml/edtf-date.biblatex view
@@ -0,0 +1,98 @@+@article{item3-3, date={1998/unknown}}+@article{item3-4, date={1999/open}}+@article{item3-10, date={2004-04-05T14:34:00}}+@article{item5-1, date={0000}}+@article{item5-2, date={-0876}}+@article{item5-3, date={-0877/-0866}}+@article{item5-5, date={-0343-02}}+@article{item5-8, date={1723~}}+@article{item5-9, date={1723?}}+@article{item5-10, date={1723?~}}+@article{item5-11, date={2004-22}}+@article{item5-12, date={2004-24}}+@article{item5-13, date={20uu}}+@article{item5-14, date={y-123456789}}++---+references:+- id: item3-3+ type: article-journal+ issued:+ - year: '1998'+ - {}++- id: item3-4+ type: article-journal+ issued:+ - year: '1999'+ - {}++- id: item3-10+ type: article-journal+ issued:+ - year: '2004'+ month: '4'+ day: '5'++- id: item5-1+ type: article-journal+ issued:+ - year: '-1'++- id: item5-2+ type: article-journal+ issued:+ - year: '-877'++- id: item5-3+ type: article-journal+ issued:+ - year: '-878'+ - year: '-867'++- id: item5-5+ type: article-journal+ issued:+ - year: '-344'+ month: '2'++- id: item5-8+ type: article-journal+ issued:+ - year: '1723'+ circa: '1'++- id: item5-9+ type: article-journal+ issued:+ - year: '1723'++- id: item5-10+ type: article-journal+ issued:+ - year: '1723'+ circa: '1'++- id: item5-11+ type: article-journal+ issued:+ - year: '2004'+ season: '2'++- id: item5-12+ type: article-journal+ issued:+ - year: '2004'+ season: '4'++- id: item5-13+ type: article-journal+ issued:+ - year: '2000'+ - year: '2099'++- id: item5-14+ type: article-journal+ issued:+ - year: '-123456790'+...
tests/biblio2yaml/incollection.biblatex view
@@ -112,8 +112,8 @@ given: Isadore issued: - year: '1979'- title: The limitations of human knowledge according to Al-Farabi, <span class="nocase">ibn- Bajja</span>, and Maimonides+ title: The limitations of human knowledge according to Al-Farabi, [ibn Bajja]{.nocase},+ and Maimonides title-short: Limitations of human knowledge container-title: Studies in medieval Jewish history and literature publisher: Harvard University Press
tests/biblio2yaml/itzhaki.biblatex view
@@ -62,8 +62,7 @@ - year: '1996' month: '3' day: '11'- title: Some remarks on ’<span class="nocase">t Hooft’s</span> S-matrix for black- holes+ title: Some remarks on ’[t Hooft’s]{.nocase} S-matrix for black holes version: '1' annote: An online reference from arXiv. Note the eprint and eprinttype fields. Also note that the arXiv reference is transformed into a clickable link if hyperref
tests/biblio2yaml/malinowski.biblatex view
@@ -49,7 +49,7 @@ issued: - year: '1972' title: 'Argonauts of the Western Pacific: An account of native enterprise and- adventure in the <span class="nocase">Archipelagoes of Melanesian New Guinea</span>'+ adventure in the [Archipelagoes of Melanesian New Guinea]{.nocase}' title-short: Argonauts publisher: Routledge and Kegan Paul publisher-place: London
tests/biblio2yaml/murray.biblatex view
@@ -85,8 +85,7 @@ issued: - year: '1998' title: 'Alkanethiolate gold cluster molecules with core diameters from 1.5 to- 5.2 <span class="nocase">nm</span>: Core and monolayer properties as a function- of core size'+ 5.2 [nm]{.nocase}: Core and monolayer properties as a function of core size' title-short: Alkanethiolate gold cluster molecules container-title: Langmuir page: '17-30'
tests/biblio2yaml/pines.biblatex view
@@ -58,8 +58,8 @@ given: Isadore issued: - year: '1979'- title: The limitations of human knowledge according to Al-Farabi, <span class="nocase">ibn- Bajja</span>, and Maimonides+ title: The limitations of human knowledge according to Al-Farabi, [ibn Bajja]{.nocase},+ and Maimonides title-short: Limitations of human knowledge container-title: Studies in medieval Jewish history and literature publisher: Harvard University Press
tests/biblio2yaml/test-case-conversion.biblatex view
@@ -59,9 +59,9 @@ given: Ann issued: - year: '2013'- title: A title, in English, with a Proper Name and an ACRONYM and a <span class="nocase">camelCase</span>- word and some units, 400 <span class="nocase">nm</span>, 3 <span class="nocase">cm</span>,- and a quote, *Alea <span class="nocase">iacta est</span>*+ title: A title, in English, with a Proper Name and an ACRONYM and a [camelCase]{.nocase}+ word and some units, 400 [nm]{.nocase}, 3 [cm]{.nocase}, and a quote, *Alea [iacta+ est]{.nocase}* container-title: Journal language: en-US ...
tests/biblio2yaml/textnormal.biblatex view
@@ -6,5 +6,5 @@ references: - id: item1 type: book- title: The title <span class="nodecor">of this book</span>+ title: The title [of this book]{.nodecor} ...
− tests/isme.csl
@@ -1,204 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-GB">- <info>- <title>The ISME Journal</title>- <id>http://www.zotero.org/styles/the-isme-journal</id>- <link href="http://www.zotero.org/styles/the-isme-journal" rel="self"/>- <link href="http://mts-isme.nature.com/cgi-bin/main.plex?form_type=display_auth_instructions" rel="documentation"/>- <author>- <name>Jessica Leigh</name>- <email>blackwednesday@gmail.com</email>- </author>- <category citation-format="author-date"/>- <category field="biology"/>- <issn>1751-7362</issn>- <eissn>1751-7370</eissn>- <summary>The ISME Journal style, which is not the same as for Nature</summary>- <updated>2014-12-02T15:48:05+00:00</updated>- <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>- </info>- <macro name="editor">- <names variable="editor">- <name and="symbol" delimiter=", " name-as-sort-order="all" sort-separator=", " initialize-with="">- <name-part name="family" text-case="capitalize-first"/>- <name-part name="given" text-case="capitalize-first"/>- </name>- <label form="short" prefix=" (" strip-periods="true" suffix=")"/>- </names>- </macro>- <macro name="series-editor">- <names variable="original-author">- <label form="short" text-case="capitalize-first" suffix=" "/>- <name and="symbol" delimiter=", "/>- </names>- </macro>- <macro name="author">- <names variable="author">- <name name-as-sort-order="all" sort-separator=" " delimiter=", " delimiter-precedes-last="always" initialize-with=""/>- <label form="short" prefix=" (" strip-periods="true" suffix=")"/>- <et-al font-style="italic"/>- <substitute>- <names variable="editor"/>- <names variable="translator"/>- </substitute>- </names>- </macro>- <macro name="author-short">- <names variable="author">- <name form="short" and="text" delimiter=", " delimiter-precedes-last="never"/>- <et-al font-style="italic"/>- <substitute>- <names variable="editor"/>- <names variable="translator"/>- </substitute>- </names>- </macro>- <macro name="access">- <choose>- <if variable="page" match="none">- <choose>- <if variable="DOI">- <text variable="DOI" prefix="doi:"/>- </if>- <else-if variable="URL">- <text variable="URL"/>- <group prefix=" (" suffix=")">- <text term="accessed" text-case="capitalize-first" suffix=" "/>- <date variable="accessed">- <date-part name="month" suffix=" "/>- <date-part name="day" suffix=", "/>- <date-part name="year"/>- </date>- </group>- </else-if>- </choose>- </if>- </choose>- </macro>- <macro name="title">- <choose>- <if type="thesis">- <text variable="title"/>- </if>- <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">- <text variable="title"/>- </else-if>- <else>- <text variable="title"/>- </else>- </choose>- </macro>- <macro name="publisher">- <group delimiter=": ">- <text variable="publisher"/>- <text variable="publisher-place"/>- </group>- </macro>- <macro name="year-date">- <date variable="issued">- <date-part name="year"/>- </date>- </macro>- <macro name="day-month">- <date variable="issued">- <date-part name="month"/>- <date-part name="day" prefix=" "/>- </date>- </macro>- <macro name="page">- <label variable="page" suffix=" " form="short"/>- <text variable="page"/>- </macro>- <macro name="edition">- <choose>- <if is-numeric="edition">- <group delimiter=" ">- <number variable="edition" form="ordinal"/>- <text term="edition" form="short"/>- </group>- </if>- <else>- <text variable="edition" suffix="."/>- </else>- </choose>- </macro>- <citation et-al-min="3" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" collapse="year">- <layout prefix="(" suffix=")" delimiter="; ">- <group delimiter=", ">- <text macro="author-short"/>- <text macro="year-date"/>- <text variable="locator"/>- </group>- </layout>- </citation>- <bibliography hanging-indent="false" et-al-min="7" et-al-use-first="2">- <sort>- <key macro="author"/>- <key variable="title"/>- </sort>- <layout suffix=".">- <group delimiter=" ">- <text macro="author" suffix="."/>- <text macro="year-date" prefix="(" suffix=")."/>- </group>- <choose>- <if type="article-newspaper article-magazine" match="any">- <group delimiter=" ">- <text macro="title" prefix=" " suffix="."/>- </group>- <group prefix=" " delimiter=", ">- <text variable="container-title"/>- <text macro="day-month"/>- <text variable="edition"/>- </group>- </if>- <else-if type="thesis">- <text macro="title" prefix=" " suffix="."/>- <group prefix=" " delimiter=", ">- <text macro="edition"/>- <text macro="editor" suffix="."/>- <text variable="genre"/>- <text macro="publisher"/>- </group>- </else-if>- <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">- <group delimiter=" ">- <text macro="title" prefix=" " suffix="."/>- <text macro="edition"/>- <text macro="publisher"/>- </group>- </else-if>- <else-if type="chapter paper-conference" match="any">- <group delimiter=" ">- <text macro="title" prefix=" " suffix="."/>- <group prefix="In:" delimiter=", " suffix=".">- <text variable="container-title" font-style="italic"/>- <group delimiter=" ">- <text macro="editor" prefix=" "/>- <text variable="collection-title"/>- <text variable="volume" prefix="Vol. "/>- <text macro="series-editor"/>- </group>- <text macro="publisher" prefix=" "/>- <text macro="page" prefix=" "/>- </group>- </group>- </else-if>- <else>- <group suffix=".">- <text macro="title" prefix=" "/>- <text macro="editor" prefix=" "/>- </group>- <group prefix=" " suffix="." delimiter=" ">- <text variable="container-title" form="short" strip-periods="true" font-style="italic"/>- <group delimiter=":">- <text variable="volume" font-weight="bold"/>- <text variable="page"/>- </group>- </group>- </else>- </choose>- <text prefix=" " macro="access" suffix="."/>- </layout>- </bibliography>-</style>
tests/test-pandoc-citeproc.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Main where import JSON import System.Process@@ -82,7 +83,11 @@ showDiff (writeNative def expectedDoc) (writeNative def outDoc) when regenerate $ UTF8.writeFile ("tests/" ++ csl ++ ".expected.native") $- writeNative def{ writerStandalone = True } outDoc+#if MIN_VERSION_pandoc(1,19,0)+ writeNative def{ writerTemplate = Just "" } outDoc+#else+ writeNative def{ writerStandalone = True } outDoc+#endif return Failed else do err "ERROR"