diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-03-30 16:43:17 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-03-30 16:43:17 +0200 |
commit | 6ad486c3c3922e4ac7dd5710f69c3ccf623e92b4 (patch) | |
tree | 0c9b584c5adf2a4ecf6ab862b3c736b2c1a7186a | |
parent | 2f19b5daac4da2b849b5165f9eb1386ab41ccc1b (diff) | |
download | pandoc-6ad486c3c3922e4ac7dd5710f69c3ccf623e92b4.tar.gz |
Automatically include URI-encoded jats.csl for jats output.
This way people can do
pandoc -s -t jats --filter pandoc-citeproc
and it will just work. If they want to specify a stylesheet,
they still can.
-rw-r--r-- | COPYRIGHT | 5 | ||||
-rw-r--r-- | data/jats.csl | 208 | ||||
-rw-r--r-- | pandoc.cabal | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/App.hs | 10 |
4 files changed, 223 insertions, 2 deletions
@@ -110,3 +110,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------ The template pandoc.jats is Copyright 2013--15 Martin Fenner, released under GPL version 2 or later. + +The file data/jats.csl is derived from a csl file by Martin Fenner, +revised by Martin Paul Eve and then John MacFarlane. +"This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 +License. Originally by Martin Fenner." diff --git a/data/jats.csl b/data/jats.csl new file mode 100644 index 000000000..64872863c --- /dev/null +++ b/data/jats.csl @@ -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> + diff --git a/pandoc.cabal b/pandoc.cabal index 33694dec0..1dfa74482 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -111,6 +111,8 @@ Data-Files: data/pandoc.lua -- bash completion template data/bash_completion.tpl + -- jats csl + data/jats.csl -- documentation MANUAL.txt, COPYRIGHT Extra-Source-Files: diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 0fc883792..e45d10254 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -73,7 +73,7 @@ import Text.Pandoc.Lua ( runLuaFilter ) import Text.Pandoc.MediaBag (MediaBag, extractMediaBag, mediaDirectory) import Text.Pandoc.PDF (makePDF) import Text.Pandoc.Process (pipeProcess) -import Text.Pandoc.SelfContained (makeSelfContained) +import Text.Pandoc.SelfContained (makeSelfContained, makeDataURI) import Text.Pandoc.Shared (err, headerShift, openURL, readDataFile, readDataFileUTF8, safeRead, tabFilter) import qualified Text.Pandoc.UTF8 as UTF8 @@ -386,10 +386,16 @@ convertWithOpts opts = do withMediaBag . r readerOpts) sources return (mconcat (map fst pairs), mconcat (map snd pairs)) + jatsCSL <- readDataFile datadir "jats.csl" + let jatsEncoded = makeDataURI ("application/xml", jatsCSL) + let metadata = if format == "jats" + then ("csl", jatsEncoded) : optMetadata opts + else optMetadata opts + runIO' $ do (doc, media) <- sourceToDoc sources doc' <- (maybe return (extractMedia media) (optExtractMedia opts) >=> - return . flip (foldr addMetadata) (optMetadata opts) >=> + return . flip (foldr addMetadata) metadata >=> applyTransforms transforms >=> applyLuaFilters datadir (optLuaFilters opts) [format] >=> applyFilters datadir filters' [format]) doc |