pandoc-citeproc 0.14.1.4 → 0.14.1.5
raw patch · 9 files changed
+596/−21 lines, 9 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog +6/−0
- pandoc-citeproc.cabal +1/−1
- src/Text/CSL/Eval/Output.hs +5/−2
- src/Text/CSL/Util.hs +2/−2
- tests/annales.csl +334/−0
- tests/issue322.expected.native +5/−0
- tests/issue322.in.native +2/−0
- tests/jats.csl +208/−0
- tests/test-pandoc-citeproc.hs +33/−16
changelog view
@@ -1,3 +1,9 @@+pandoc-citeproc (0.14.1.5)++ * Fixed 'capitalize-first' when the element begins with emphasis+ or some other inline container. Closes #322.+ * test-pandoc-citeproc: make --accept work with biblio2yaml tests.+ pandoc-citeproc (0.14.1.4) * Fixed sort order bugs (#320):
pandoc-citeproc.cabal view
@@ -1,5 +1,5 @@ name: pandoc-citeproc-version: 0.14.1.4+version: 0.14.1.5 cabal-version: >= 1.12 synopsis: Supports using pandoc with citeproc
src/Text/CSL/Eval/Output.hs view
@@ -213,7 +213,7 @@ _ -> ils text_case (Formatted []) = Formatted []- text_case (Formatted ils@(i:is))+ text_case (Formatted ils@(i:is')) | noCase f = Formatted [Span ("",["nocase"],[]) ils] | otherwise = Formatted $ case textCase f of@@ -221,7 +221,10 @@ "uppercase" -> walk uppercaseStr ils "capitalize-all" -> walk capitalizeStr ils "title" -> titlecase ils- "capitalize-first" -> walk capitalizeStr i : is+ "capitalize-first"+ -> case i of+ Str cs -> Str (capitalize cs) : is'+ _ -> unTitlecase [i] ++ is' "sentence" -> unTitlecase ils _ -> ils
src/Text/CSL/Util.hs view
@@ -344,8 +344,8 @@ go acc (Quoted qt xs) = (:acc) <$> (Quoted qt <$> caseTransform xform xs) go acc (Emph xs) = (:acc) <$> (Emph <$> caseTransform xform xs) go acc (Strong xs) = (:acc) <$> (Strong <$> caseTransform xform xs)- go acc (Link at xs t) = (:acc) <$> (Link at <$> caseTransform xform xs <*> pure t)- go acc (Image at xs t) = (:acc) <$> (Link at <$> caseTransform xform xs <*> pure t)+ go acc (Link at xs t) = (:acc) <$> (Link at <$> caseTransform xform xs <*> pure t)+ go acc (Image at xs t) = (:acc) <$> (Link at <$> caseTransform xform xs <*> pure t) go acc (Span attr xs) = (:acc) <$> (Span attr <$> caseTransform xform xs) go acc x = return $ x : acc
+ tests/annales.csl view
@@ -0,0 +1,334 @@+<?xml version="1.0" encoding="utf-8"?>+<style xmlns="http://purl.org/net/xbiblio/csl" class="note" default-locale="fr-FR" version="1.0" page-range-format="expanded" demote-non-dropping-particle="sort-only">+ <info>+ <title>Annales. Histoire, Sciences sociales (French)</title>+ <id>http://www.zotero.org/styles/annales</id>+ <link href="http://www.zotero.org/styles/annales" rel="self"/>+ <link href="http://annales.ehess.fr/?lang=en/" rel="documentation"/>+ <author>+ <name>Franziska Heimburger</name>+ <email>zotero@franziska.fr</email>+ </author>+ <category citation-format="note"/>+ <category field="social_science"/>+ <issn>0395-2649</issn>+ <updated>2013-08-29T04:18:55+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>+ <locale xml:lang="fr">+ <terms>+ <term name="ordinal-01">ère</term>+ <term name="ordinal-02">e</term>+ <term name="ordinal-03">e</term>+ <term name="ordinal-04">e</term>+ <term name="cited">op. cit.</term>+ <term name="page" form="short">+ <single>p.</single>+ <multiple>p.</multiple>+ </term>+ <term name="editor" form="short">+ <single>dir.</single>+ <multiple>dir.</multiple>+ </term>+ </terms>+ </locale>+ <macro name="author">+ <names variable="author">+ <name form="long" and="text" delimiter-precedes-last="never">+ <name-part name="family" font-variant="small-caps"/>+ </name>+ <label form="short" prefix=" (" suffix=")"/>+ <substitute>+ <names variable="editor"/>+ <names variable="translator"/>+ <text macro="title"/>+ </substitute>+ </names>+ </macro>+ <macro name="author-short">+ <names variable="author">+ <name form="long" and="text" initialize-with=". " delimiter-precedes-last="never">+ <name-part name="family" font-variant="small-caps"/>+ </name>+ <label form="short" prefix=" (" suffix=")"/>+ <substitute>+ <names variable="editor"/>+ <names variable="translator"/>+ <text macro="title"/>+ </substitute>+ </names>+ </macro>+ <macro name="editor">+ <names variable="editor">+ <name form="long" and="text" delimiter-precedes-last="never" sort-separator=" " font-style="normal">+ </name>+ <label form="short" prefix=" (" suffix=".)"/>+ </names>+ </macro>+ <macro name="translator">+ <names variable="translator">+ <name form="long" and="text" delimiter-precedes-last="never" sort-separator=" " font-style="normal" prefix=" trad. fr. ">+ <name-part name="family" font-variant="small-caps"/>+ </name>+ </names>+ </macro>+ <macro name="title">+ <choose>+ <if type="bill book graphic legal_case motion_picture report song" match="any">+ <text variable="title" text-case="capitalize-first" font-style="italic"/>+ </if>+ <else-if type="article-journal article-newspaper article-magazine" match="any">+ <group delimiter=", ">+ <text variable="title" text-case="capitalize-first" quotes="true" font-style="normal"/>+ <text variable="container-title" font-style="italic"/>+ </group>+ </else-if>+ <else-if type="thesis" match="any">+ <group>+ <text variable="title" text-case="capitalize-first" quotes="true" font-style="normal"/>+ <text variable="genre" suffix=", " prefix=" "/>+ <text variable="publisher"/>+ </group>+ </else-if>+ <else-if type="manuscript" match="any">+ <group delimiter=",">+ <text variable="title" text-case="capitalize-first" quotes="true" font-style="normal"/>+ <text variable="genre" prefix=" "/>+ </group>+ </else-if>+ <else-if type="chapter entry-dictionary entry-encyclopedia" match="any">+ <group>+ <text variable="title" text-case="capitalize-first" quotes="true" suffix=","/>+ <text value="in" font-style="italic" suffix=" " prefix=" "/>+ <text macro="editor" suffix=", "/>+ <text variable="container-title" text-case="capitalize-first" font-style="italic"/>+ </group>+ </else-if>+ <else-if type="webpage" match="any">+ <group>+ <text variable="title" text-case="capitalize-first" font-style="italic" suffix=", "/>+ <text variable="URL" text-decoration="underline"/>+ </group>+ </else-if>+ <else>+ <text variable="title" quotes="true"/>+ </else>+ </choose>+ </macro>+ <macro name="pub-place">+ <choose>+ <if type="bill book chapter entry-dictionary entry-encyclopedia thesis graphic legal_case manuscript motion_picture paper-conference report song" match="any">+ <text variable="publisher-place"/>+ </if>+ </choose>+ </macro>+ <macro name="publisher">+ <choose>+ <if type="bill book chapter entry-dictionary entry-encyclopedia graphic legal_case motion_picture paper-conference report song" match="any">+ <text variable="publisher"/>+ </if>+ </choose>+ </macro>+ <macro name="yearpage">+ <choose>+ <if type="bill book graphic legal_case motion_picture paper-conference manuscript report song thesis" match="any">+ <group delimiter=", " font-style="normal">+ <date variable="issued">+ <date-part name="year"/>+ </date>+ <group delimiter=" ">+ <text term="volume" form="short"/>+ <text variable="volume"/>+ </group>+ <group delimiter=" ">+ <label variable="locator" form="short"/>+ <text variable="locator"/>+ </group>+ </group>+ </if>+ <else-if type="chapter entry-dictionary entry-encyclopedia" match="any">+ <group delimiter=" " font-style="normal">+ <date variable="issued">+ <date-part name="year" suffix=", "/>+ </date>+ <group>+ <text term="volume" form="short" suffix="."/>+ <text variable="number-of-volumes" prefix=". " suffix="/"/>+ <text variable="volume" suffix=","/>+ </group>+ <label variable="page" form="short"/>+ <group delimiter=", ">+ <text variable="page"/>+ <group delimiter=" ">+ <label variable="locator" form="short"/>+ <text variable="locator"/>+ </group>+ </group>+ </group>+ </else-if>+ <else-if type="article-journal" match="any">+ <group delimiter=" " font-style="normal">+ <label variable="page" form="short"/>+ <group delimiter=", ">+ <text variable="page"/>+ <group delimiter=" ">+ <label variable="locator" form="short"/>+ <text variable="locator"/>+ </group>+ </group>+ </group>+ </else-if>+ <else-if type="article-newspaper article-magazine" match="any">+ <group delimiter=" " font-style="normal">+ <date variable="issued" form="numeric">+ <date-part name="day"/>+ <date-part name="month"/>+ <date-part name="year"/>+ </date>+ <group delimiter=" " font-style="normal">+ <choose>+ <if variable="locator" match="any">+ <group delimiter=" ">+ <label variable="locator" form="short"/>+ <text variable="locator"/>+ </group>+ </if>+ <else-if variable="locator" match="none">+ <label variable="page" form="short"/>+ </else-if>+ </choose>+ </group>+ </group>+ </else-if>+ <else-if type="webpage" match="any">+ <group delimiter=" " font-style="normal">+ <text value="consulté le" suffix=" " prefix=" "/>+ <date variable="accessed" form="text">+ <date-part name="day"/>+ <date-part name="month"/>+ <date-part name="year"/>+ </date>+ </group>+ </else-if>+ </choose>+ </macro>+ <macro name="edition">+ <choose>+ <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">+ <choose>+ <if is-numeric="edition">+ <group delimiter=" ">+ <number variable="edition" form="ordinal"/>+ <text term="edition" form="short"/>+ </group>+ </if>+ <else>+ <text variable="edition" text-case="capitalize-first" suffix="."/>+ </else>+ </choose>+ </if>+ <else-if type="article-journal article-magazine" match="any">+ <group font-style="normal">+ <choose>+ <if variable="issued">+ <date variable="issued">+ <date-part name="year"/>+ </date>+ <text macro="volume" prefix=", "/>+ </if>+ <else>+ <text macro="volume" text-case="capitalize-first"/>+ </else>+ </choose>+ </group>+ </else-if>+ </choose>+ <text macro="issue" prefix=", "/>+ </macro>+ <macro name="volume">+ <choose>+ <if is-numeric="volume">+ <text term="volume" form="short" suffix=". "/>+ <text variable="volume"/>+ </if>+ <else>+ <text variable="volume"/>+ </else>+ </choose>+ </macro>+ <macro name="issue">+ <choose>+ <if is-numeric="issue">+ <text term="issue" form="short" suffix=" "/>+ <text variable="issue"/>+ </if>+ <else>+ <text variable="issue"/>+ </else>+ </choose>+ </macro>+ <citation>+ <layout suffix="." delimiter=" ; ">+ <choose>+ <if position="ibid-with-locator">+ <group delimiter=", ">+ <text term="ibid" text-case="capitalize-first" font-style="italic" suffix="."/>+ <group delimiter=" ">+ <label variable="locator" form="short"/>+ <text variable="locator"/>+ </group>+ </group>+ </if>+ <else-if position="ibid">+ <text term="ibid" text-case="capitalize-first" font-style="italic"/>+ </else-if>+ <else-if position="subsequent">+ <group delimiter=", ">+ <text macro="author-short"/>+ <choose>+ <if type="bill book graphic legal_case motion_picture report song thesis" match="any">+ <text variable="title" form="short" font-style="italic"/>+ </if>+ <else>+ <text variable="title" text-case="capitalize-first" form="short" quotes="true" font-style="normal"/>+ </else>+ </choose>+ <text term="cited" font-style="italic" suffix="."/>+ <group delimiter=" ">+ <label variable="locator" form="short"/>+ <text variable="locator"/>+ </group>+ </group>+ </else-if>+ <else>+ <group delimiter=", ">+ <text macro="author"/>+ <text macro="title"/>+ <text macro="translator"/>+ <text macro="edition"/>+ <text macro="pub-place"/>+ <text macro="publisher"/>+ <text macro="yearpage"/>+ </group>+ </else>+ </choose>+ </layout>+ </citation>+ <bibliography>+ <sort>+ <key macro="author" names-min="3" names-use-first="3"/>+ <key variable="issued" sort="descending"/>+ </sort>+ <layout suffix=".">+ <group delimiter=", ">+ <text macro="author"/>+ <text macro="title"/>+ <text macro="translator"/>+ <text macro="edition"/>+ <text macro="pub-place"/>+ <text macro="publisher"/>+ <text macro="yearpage"/>+ </group>+ </layout>+ </bibliography>+</style>
+ tests/issue322.expected.native view
@@ -0,0 +1,5 @@+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/annales.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Timmory"]),("given",MetaInlines [Str "Fran\231ois"])])]),("container-title",MetaInlines [Str "L\8217\201cran",Space,Str "fran\231ais"]),("id",MetaInlines [Str "timmory__justice_1950"]),("issue",MetaInlines [Str "272"]),("issued",MetaList [MetaMap (fromList [("day",MetaString "25"),("month",MetaString "9"),("year",MetaString "1950")])]),("language",MetaInlines [Str "fr-FR"]),("page",MetaInlines [Str "12"]),("title",MetaInlines [Emph [Str "Justice",Space,Str "est",Space,Str "faite"],Space,Str ":",Space,Str "soyons",Space,Str "justes"]),("type",MetaInlines [Str "article-journal"])])])]})+[Para [Str "Foo",Cite [Citation {citationId = "timmory__justice_1950", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 1}] [Note [Para [Str "Fran\231ois",Space,SmallCaps [Str "Timmory"],Str ",",Space,Str "\171\160",Emph [Str "Justice",Space,Str "est",Space,Str "faite"],Space,Str ":",Space,Str "soyons",Space,Str "justes\160\187,",Space,Emph [Str "L\8217\201cran",Space,Str "fran\231ais"],Str ",",Space,Str "1950,",Space,Str "n\7506\160\&272,",Space,Str "p.",Space,Str "12."]]],Str "."]+,Div ("refs",["references"],[])+ [Div ("ref-timmory__justice_1950",[],[])+ [Para [Str "Fran\231ois",Space,SmallCaps [Str "Timmory"],Str ",",Space,Str "\171\160",Emph [Str "Justice",Space,Str "est",Space,Str "faite"],Space,Str ":",Space,Str "soyons",Space,Str "justes\160\187,",Space,Emph [Str "L\8217\201cran",Space,Str "fran\231ais"],Str ",",Space,Str "1950,",Space,Str "n\7506\160\&272,",Space,Str "p.",Space,Str "12."]]]]
+ tests/issue322.in.native view
@@ -0,0 +1,2 @@+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/annales.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Timmory"]),("given",MetaInlines [Str "Fran\231ois"])])]),("container-title",MetaInlines [Str "L\8217\201cran",Space,Str "fran\231ais"]),("id",MetaInlines [Str "timmory__justice_1950"]),("issue",MetaInlines [Str "272"]),("issued",MetaList [MetaMap (fromList [("day",MetaString "25"),("month",MetaString "9"),("year",MetaString "1950")])]),("language",MetaInlines [Str "fr-FR"]),("page",MetaInlines [Str "12"]),("title",MetaInlines [Emph [Str "Justice",Space,Str "est",Space,Str "faite"],Space,Str ":",Space,Str "soyons",Space,Str "justes"]),("type",MetaInlines [Str "article-journal"])])])]})+[Para [Str "Foo",Cite [Citation {citationId = "timmory__justice_1950", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@timmory__justice_1950]"],Str "."]]
+ tests/jats.csl view
@@ -0,0 +1,208 @@+<?xml version="1.0" encoding="utf-8"?>+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" default-locale="en-US">+ <info>+ <title>Journal Article Tag Suite</title>+ <title-short>JATS</title-short>+ <id>http://www.zotero.org/styles/journal-article-tag-suite</id>+ <link href="https://github.com/MartinPaulEve/JATS-CSL/blob/master/jats.csl" rel="self"/>+ <link rel="documentation" href="http://jats.nlm.nih.gov/archiving/tag-library/1.0/index.html"/>+ <author>+ <name>Martin Paul Eve</name>+ <email>martin@martineve.com</email>+ </author>+ <category citation-format="numeric"/>+ <category field="medicine"/>+ <category field="biology"/>+ <summary>Use this style to generate bibliographic data in Journal Article Tagging Suite (JATS) 1.0 XML format</summary>+ <updated>2014-06-21T17:41:26+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. Originally by Martin Fenner.</rights>+ </info>+ <locale xml:lang="en">+ <terms>+ <term name="et-al">{{jats}}<etal/>{{/jats}}</term>+ </terms>+ </locale>+ <macro name="citation-number">+ <text variable="citation-number" prefix="{{jats}}id="ref-{{/jats}}" suffix="{{jats}}">{{/jats}}"/>+ </macro>+ <macro name="author">+ <names variable="author">+ <name prefix="{{jats}}<name>{{/jats}}" suffix="{{jats}}</name>{{/jats}}" name-as-sort-order="all" sort-separator="">+ <name-part name="family" text-case="capitalize-first" prefix="{{jats}}<surname>{{/jats}}" suffix="{{jats}}</surname>{{/jats}}"/>+ <name-part name="given" text-case="capitalize-first" prefix="{{jats}}<given-names>{{/jats}}" suffix="{{jats}}</given-names>{{/jats}}"/>+ </name>+ <substitute>+ <names variable="editor"/>+ </substitute>+ </names>+ </macro>++ <macro name="editor">+ <names variable="editor" prefix="{{jats}}<person-group person-group-type="editor">{{/jats}}" suffix="{{jats}}</person-group>{{/jats}}">+ <name prefix="{{jats}}<name>{{/jats}}" suffix="{{jats}}</name>{{/jats}}" name-as-sort-order="all" sort-separator="">+ <name-part name="family" text-case="capitalize-first" prefix="{{jats}}<surname>{{/jats}}" suffix="{{jats}}</surname>{{/jats}}"/>+ <name-part name="given" text-case="capitalize-first" prefix="{{jats}}<given-names>{{/jats}}" suffix="{{jats}}</given-names>{{/jats}}"/>+ </name>+ <substitute>+ <names variable="editor"/>+ </substitute>+ </names>+ </macro>++ <macro name="editor">+ <group delimiter=": ">+ <names variable="editor">+ <name prefix="{{jats}}<name>{{/jats}}" suffix="{{jats}}</name>{{/jats}}" name-as-sort-order="all" sort-separator="">+ <name-part name="family" text-case="capitalize-first" prefix="{{jats}}<surname>{{/jats}}" suffix="{{jats}}</surname>{{/jats}}"/>+ <name-part name="given" text-case="capitalize-first" prefix="{{jats}}<given-names>{{/jats}}" suffix="{{jats}}<given-names>{{/jats}}"/>+ </name>+ </names>+ </group>+ </macro>+ <macro name="title">+ <choose>+ <if type="book" match="any">+ <group prefix="{{jats}}<source>{{/jats}}" suffix="{{jats}}</source>{{/jats}}">+ <text variable="title"/>+ </group> + </if>+ <else>+ <group prefix="{{jats}}<article-title>{{/jats}}" suffix="{{jats}}</article-title>{{/jats}}">+ <text variable="title"/>+ </group>+ </else>+ </choose>+ </macro>+ <macro name="container-title">+ <text variable="container-title" form="short" prefix="{{jats}}<source>{{/jats}}" suffix="{{jats}}</source>{{/jats}}"/>+ </macro>+ <macro name="publisher">+ <text variable="publisher" prefix="{{jats}}<publisher-name>{{/jats}}" suffix="{{jats}}</publisher-name>{{/jats}}"/>+ <text variable="publisher-place" prefix="{{jats}}<publisher-loc>{{/jats}}" suffix="{{jats}}</publisher-loc>{{/jats}}"/>+ </macro>+ <macro name="link">+ <choose>+ <if match="any" variable="DOI">+ <group prefix="{{jats}}<pub-id pub-id-type="doi">{{/jats}}" suffix="{{jats}}</pub-id>{{/jats}}">+ <text variable="DOI"/>+ </group>+ </if>+ </choose>+ <choose>+ <if match="any" variable="PMID">+ <group prefix="{{jats}}<ext-link ext-link-type="pmid" {{/jats}}" suffix="{{jats}}</ext-link>{{/jats}}">+ <text variable="PMID" prefix="{{jats}}xlink:href="http://www.ncbi.nlm.nih.gov/pubmed/{{/jats}}" suffix="{{jats}}" xlink:type="simple">{{/jats}}"/>+ <text variable="PMID"/>+ </group>+ </if>+ </choose>+ <choose>+ <if variable="URL" match="any">+ <group prefix="{{jats}}<ext-link ext-link-type="uri" {{/jats}}" suffix="{{jats}}</ext-link>{{/jats}}">+ <text variable="URL" prefix="{{jats}}xlink:href="{{/jats}}" suffix="{{jats}}" xlink:type="simple">{{/jats}}"/>+ <text variable="URL"/>+ </group>+ </if>+ </choose>+ </macro>+ <macro name="date">+ <choose>+ <if type="article-journal article-magazine article-newspaper report patent book" match="any">+ <group prefix="{{jats}}<date>{{/jats}}" suffix="{{jats}}</date>{{/jats}}">+ <date variable="issued">+ <date-part name="day" form="numeric-leading-zeros" prefix="{{jats}}<day>{{/jats}}" suffix="{{jats}}</day>{{/jats}}"/>+ <date-part name="month" form="numeric-leading-zeros" prefix="{{jats}}<month>{{/jats}}" suffix="{{jats}}</month>{{/jats}}"/>+ <date-part name="year" prefix="{{jats}}<year>{{/jats}}" suffix="{{jats}}</year>{{/jats}}"/>+ </date>+ </group>+ </if>+ <else>+ <group prefix="{{jats}}<date-in-citation content-type="access-date"{{/jats}}" suffix="{{jats}}</date-in-citation>{{/jats}}">+ <date variable="accessed" prefix="{{jats}} iso-8601-date="{{/jats}}" suffix="{{jats}}">{{/jats}}">+ <date-part name="year"/>+ <date-part name="month" form="numeric-leading-zeros" prefix="{{jats}}-{{/jats}}"/>+ <date-part name="day" form="numeric-leading-zeros" prefix="{{jats}}-{{/jats}}"/>+ </date>+ <date variable="accessed">+ <date-part name="day" prefix="{{jats}}<day>{{/jats}}" suffix="{{jats}}</day>{{/jats}}"/>+ <date-part name="month" form="numeric-leading-zeros" prefix="{{jats}}<month>{{/jats}}" suffix="{{jats}}</month>{{/jats}}"/>+ <date-part name="year" prefix="{{jats}}<year>{{/jats}}" suffix="{{jats}}</year>{{/jats}}"/>+ </date>+ </group>+ </else>+ </choose>+ </macro>+ <macro name="location">+ <choose>+ <if type="article-journal article-magazine" match="any">+ <text variable="volume" prefix="{{jats}}<volume>{{/jats}}" suffix="{{jats}}</volume>{{/jats}}"/>+ <text variable="issue" prefix="{{jats}}<issue>{{/jats}}" suffix="{{jats}}</issue>{{/jats}}"/>+ </if>+ </choose>+ <choose>+ <if type="article-journal article-magazine article-newspaper chapter" match="any">+ <text variable="page-first" prefix="{{jats}}<fpage>{{/jats}}" suffix="{{jats}}</fpage>{{/jats}}"/>+ </if>+ </choose>+ </macro>+ <macro name="publication-type">+ <group prefix="{{jats}} publication-type="{{/jats}}" suffix="{{jats}}">{{/jats}}">+ <choose>+ <if type="article-journal article-magazine article-newspaper" match="any">+ <text value="journal"/>+ </if>+ <else-if type="book" match="any">+ <text value="book"/>+ </else-if>+ <else-if type="chapter" match="any">+ <text value="bookchapter"/>+ </else-if>+ <else-if type="dataset" match="any">+ <text value="dataset"/>+ </else-if>+ <else-if type="patent" match="any">+ <text value="patent"/>+ </else-if>+ <else-if type="report" match="any">+ <text value="report"/>+ </else-if>+ <else-if type="review" match="any">+ <text value="review"/>+ </else-if>+ <else>+ <text value="standard"/>+ </else>+ </choose>+ </group>+ </macro>+ <citation collapse="citation-number">+ <sort>+ <key variable="citation-number"/>+ </sort>+ <layout delimiter=",">+ <group prefix="{{jats}}<xref ref-type="bibr" rid="{{/jats}}" suffix="{{jats}}</xref>{{/jats}}">+ <text variable="citation-number" prefix="{{jats}}ref-{{/jats}}" suffix="{{jats}}">{{/jats}}"/>+ <text variable="citation-number"/>+ </group>+ </layout>+ </citation>+ <bibliography sort-separator="">+ <layout>+ <group prefix="{{jats}}<ref {{/jats}}" suffix="{{jats}}</ref>{{/jats}}">+ <text macro="citation-number"/>+ <group prefix="{{jats}}<element-citation{{/jats}}" suffix="{{jats}}</element-citation>{{/jats}}">+ <text macro="publication-type"/>+ <text macro="author" prefix="{{jats}}<person-group person-group-type="author">{{/jats}}" suffix="{{jats}}</person-group>{{/jats}}"/>+ <text macro="title" />+ <text macro="container-title"/>+ <text macro="editor"/>+ <text macro="publisher"/>+ <text macro="date"/>+ <text macro="location"/>+ <text macro="link"/>+ </group>+ </group>+ </layout>+ </bibliography>+</style>+
tests/test-pandoc-citeproc.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} module Main where-import Control.Monad (when) import qualified Data.Aeson as Aeson import Data.List (isSuffixOf) import Data.Maybe (fromMaybe)@@ -29,7 +28,7 @@ citeprocTests <- mapM (testCase regenerate) testnames fs <- filter (\f -> takeExtension f `elem` [".bibtex",".biblatex"]) `fmap` getDirectoryContents "tests/biblio2yaml"- biblio2yamlTests <- mapM biblio2yamlTest fs+ biblio2yamlTests <- mapM (biblio2yamlTest regenerate) fs let allTests = citeprocTests ++ biblio2yamlTests let numpasses = length $ filter (== Passed) allTests let numskipped = length $ filter (== Skipped) allTests@@ -71,17 +70,21 @@ let outDoc = fromMaybe mempty $Aeson.decode jsonOut if outDoc == expectedDoc then err "PASSED" >> return Passed- else do- err "FAILED"- showDiff (writeNative expectedDoc) (writeNative outDoc)- when regenerate $- UTF8.writeFile ("tests/" ++ csl ++ ".expected.native") $+ else+ if regenerate+ then do+ UTF8.writeFile ("tests/" ++ csl ++ ".expected.native") $ #if MIN_VERSION_pandoc(1,19,0)- writeNative outDoc+ writeNative outDoc #else- writeNative outDoc+ writeNative outDoc #endif- return Failed+ err "PASSED (accepted)"+ return Passed+ else do+ err "FAILED"+ showDiff (writeNative expectedDoc) (writeNative outDoc)+ return Failed else do err "ERROR" err $ "Error status " ++ show ec@@ -99,8 +102,8 @@ _ <- rawSystem "diff" ["-U1","expected","actual"] setCurrentDirectory oldDir -biblio2yamlTest :: String -> IO TestResult-biblio2yamlTest fp = do+biblio2yamlTest :: Bool -> String -> IO TestResult+biblio2yamlTest regenerate fp = do hPutStr stderr $ "[biblio2yaml/" ++ fp ++ "] " let yamld = "tests/biblio2yaml/" #if MIN_VERSION_pandoc(2,0,0)@@ -129,10 +132,24 @@ then do if expected == result then err "PASSED" >> return Passed- else do- err $ "FAILED"- showDiff expected result- return Failed+ else+ if regenerate+ then do+ let accepted = bib ++ result+#if MIN_VERSION_pandoc(2,0,0)+ p2version <- doesFileExist (yamld ++ "/pandoc-2/" ++ fp)+ UTF8.writeFile (if p2version+ then (yamld ++ "/pandoc-2/" ++ fp)+ else (yamld ++ fp)) accepted+#else+ UTF8.writeFile (yamld ++ fp) accepted+#endif+ err "PASSED (accepted)"+ return Passed+ else do+ err $ "FAILED"+ showDiff expected result+ return Failed else do err "ERROR" err $ "Error status " ++ show ec