git.iko.soy/typeable/pandoc
on master help sign in
Removed dependency on citeproc-hs.

Going forward we'll use pandoc-citeproc, as an external filter. The `--bibliography`, `--csl`, and `--citation-abbreviation` fields have been removed. Instead one must include `bibliography`, `csl`, or `csl-abbrevs` fields in the document's YAML metadata. The filter can then be used as follows: pandoc --filter pandoc-citeproc The `Text.Pandoc.Biblio` module has been removed. Henceforth, `Text.CSL.Pandoc` from pandoc-citations can be used by library users. The Markdown and LaTeX readers now longer format bibliographies and citations. That must be done using `processCites` or `processCites'` from Text.CSL.Pandoc. All bibliography-related fields have been removed from `ReaderOptions` and `WriterOptions`: `writerBiblioFiles`, `readerReferences`, `readerCitationStyle`. API change.

commitdeb59b62354e38df9c85ce6985e5c28dd2301ee7 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 24 Aug 2013, 22:27 (13 years ago) parent74250b6
10 files changed+50−843
README+42−63 data/default.csl−458 pandoc.cabal+1−6 pandoc.hs+3−65 src/Text/Pandoc/Biblio.hs−216 src/Text/Pandoc/Options.hs−7 src/Text/Pandoc/Readers/LaTeX.hs+1−4 src/Text/Pandoc/Readers/Markdown.hs+1−4 src/Text/Pandoc/Writers/LaTeX.hs+2−6 tests/Tests/Old.hs−14
README+42−63
@@ -598,54 +598,6 @@ Options affecting specific writers
598598Citation rendering
599599------------------
600600
601−`--bibliography=`*FILE*
602−: Specify bibliography database to be used in resolving
603− citations. The database type will be determined from the
604− extension of *FILE*, which may be `.mods` (MODS format),
605− `.bib` (BibLaTeX format, which will normally work for BibTeX
606− files as well), `.bibtex` (BibTeX format),
607− `.ris` (RIS format), `.enl` (EndNote format),
608− `.xml` (EndNote XML format), `.wos` (ISI format),
609− `.medline` (MEDLINE format), `.copac` (Copac format),
610− or `.json` (citeproc JSON). If you want to use multiple
611− bibliographies, just use this option repeatedly.
612−
613−`--csl=`*FILE*
614−: Specify [CSL] style to be used in formatting citations and
615− the bibliography. If *FILE* is not found, pandoc will look
616− for it in
617−
618− $HOME/.csl
619−
620− in unix,
621−
622− C:\Documents And Settings\USERNAME\Application Data\csl
623−
624− in Windows XP, and
625−
626− C:\Users\USERNAME\AppData\Roaming\csl
627−
628− in Windows 7. If the `--csl` option is not specified, pandoc
629− will use a default style: either `default.csl` in the
630− user data directory (see `--data-dir`), or, if that is
631− not present, the Chicago author-date style.
632−
633−`--citation-abbreviations=`*FILE*
634−: Specify a file containing abbreviations for journal titles and
635− other bibliographic fields (indicated by setting `form="short"`
636− in the CSL node for the field). The format is described at
637− <http://citationstylist.org/2011/10/19/abbreviations-for-zotero-test-release/>.
638− Here is a short example:
639−
640− { "default": {
641− "container-title": {
642− "Lloyd's Law Reports": "Lloyd's Rep",
643− "Estates Gazette": "EG",
644− "Scots Law Times": "SLT"
645− }
646− }
647− }
648−
649601`--natbib`
650602: Use natbib for citations in LaTeX output.
651603
@@ -2378,9 +2330,14 @@ Citations
23782330
23792331**Extension: `citations`**
23802332
2381−Pandoc can automatically generate citations and a bibliography in a number of
2382−styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,
2383−you will need a bibliographic database in one of the following formats:
2333+Using an external filter, `pandoc-citeproc`, pandoc can automatically generate
2334+citations and a bibliography in a number of styles. Basic usage is
2335+
2336+ pandoc --filter pandoc-citeproc myinput.txt
2337+
2338+In order to use this feature, you will need to specify a bibliography file
2339+using the `bibliography` metadata field in a YAML metadata section.
2340+The bibliography may have any of these formats:
23842341
23852342 Format File extension
23862343 ------------ --------------
@@ -2398,18 +2355,40 @@ you will need a bibliographic database in one of the following formats:
23982355Note that `.bib` can generally be used with both BibTeX and BibLaTeX
23992356files, but you can use `.bibtex` to force BibTeX.
24002357
2401−You will need to specify the bibliography file using the `--bibliography`
2402−command-line option (which may be repeated if you have several
2403−bibliographies).
2404−
2405−By default, pandoc will use a Chicago author-date format for citations
2406−and references. To use another style, you will need to use the
2407−`--csl` option to specify a [CSL] 1.0 style file. A primer on
2408−creating and modifying CSL styles can be found at
2409−<http://citationstyles.org/downloads/primer.html>.
2410−A repository of CSL styles can be found at
2411−<https://github.com/citation-style-language/styles>.
2412−See also <http://zotero.org/styles> for easy browsing.
2358+Alternatively you can use a `references` field in the document's YAML
2359+metadata. This should include an array of YAML-encoded references,
2360+for example:
2361+
2362+ ---
2363+ references:
2364+ - id: fenner2012a
2365+ title: One-click science marketing
2366+ author:
2367+ - family: Fenner
2368+ given: Martin
2369+ container-title: Nature Materials
2370+ volume: 11
2371+ URL: 'http://dx.doi.org/10.1038/nmat3283'
2372+ DOI: 10.1038/nmat3283
2373+ issue: 4
2374+ publisher: Nature Publishing Group
2375+ page: 261-263
2376+ type: article-journal
2377+ issued:
2378+ year: 2012
2379+ month: 3
2380+ ...
2381+
2382+(The program `mods2yaml`, which comes with `pandoc-citeproc`, can help produce
2383+these from a MODS reference collection.)
2384+
2385+By default, `pandoc-citeproc` will use a Chicago author-date format for
2386+citations and references. To use another style, you will need to specify
2387+a [CSL] 1.0 style file in the `csl` metadata field. A primer on creating and
2388+modifying CSL styles can be found at
2389+<http://citationstyles.org/downloads/primer.html>. A repository of CSL styles
2390+can be found at <https://github.com/citation-style-language/styles>. See also
2391+<http://zotero.org/styles> for easy browsing.
24132392
24142393Citations go inside square brackets and are separated by semicolons.
24152394Each citation must have a key, composed of '@' + the citation
data/default.csldeleted−458
@@ -1,458 +0,0 @@
1−<?xml version="1.0" encoding="utf-8"?>
2−<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
3− <info>
4− <title>Chicago Manual of Style (author-date)</title>
5− <id>http://www.zotero.org/styles/chicago-author-date</id>
6− <link href="http://www.zotero.org/styles/chicago-author-date" rel="self"/>
7− <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
8− <author>
9− <name>Julian Onions</name>
10− <email>julian.onions@gmail.com</email>
11− </author>
12− <contributor>
13− <name>Sebastian Karcher</name>
14− </contributor>
15− <contributor>
16− <name>Richard Karnesky</name>
17− <email>karnesky+zotero@gmail.com</email>
18− <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
19− </contributor>
20− <category citation-format="author-date"/>
21− <category field="generic-base"/>
22− <summary>The author-date variant of the Chicago style</summary>
23− <updated>2013-03-28T05:37:10+00:00</updated>
24− <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
25− </info>
26− <locale>
27− <terms>
28− <term name="editor" form="verb-short">ed.</term>
29− <term name="container-author" form="verb">by</term>
30− <term name="translator" form="verb-short">trans.</term>
31− <term name="translator" form="short">trans.</term>
32− </terms>
33− </locale>
34− <macro name="secondary-contributors">
35− <choose>
36− <if type="chapter paper-conference" match="none">
37− <group delimiter=". ">
38− <names variable="editor translator">
39− <label form="verb" text-case="capitalize-first" suffix=" " plural="never"/>
40− <name and="text" delimiter=", "/>
41− </names>
42− </group>
43− </if>
44− </choose>
45− </macro>
46− <macro name="container-contributors">
47− <choose>
48− <if type="chapter paper-conference" match="any">
49− <group prefix=", " delimiter=", ">
50− <names variable="container-author editor" delimiter=", ">
51− <label form="verb" suffix=" " plural="never"/>
52− <name and="text" delimiter=", "/>
53− </names>
54− </group>
55− </if>
56− </choose>
57− </macro>
58− <macro name="editor">
59− <names variable="editor">
60− <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
61− <label form="short" prefix=", "/>
62− </names>
63− </macro>
64− <macro name="translator">
65− <names variable="translator">
66− <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
67− <label form="short" prefix=", " plural="never"/>
68− </names>
69− </macro>
70− <macro name="recipient">
71− <choose>
72− <if type="personal_communication">
73− <choose>
74− <if variable="genre">
75− <text variable="genre" text-case="capitalize-first"/>
76− </if>
77− <else>
78− <text term="letter" text-case="capitalize-first"/>
79− </else>
80− </choose>
81− </if>
82− </choose>
83− <names variable="recipient" delimiter=", ">
84− <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
85− <name and="text" delimiter=", "/>
86− </names>
87− </macro>
88− <macro name="contributors">
89− <names variable="author">
90− <name and="text" name-as-sort-order="first" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
91− <label form="short" plural="never" prefix=", "/>
92− <substitute>
93− <names variable="editor"/>
94− <names variable="translator"/>
95− <text macro="title"/>
96− </substitute>
97− </names>
98− <text macro="recipient"/>
99− </macro>
100− <macro name="contributors-short">
101− <names variable="author">
102− <name form="short" and="text" delimiter=", " initialize-with=". "/>
103− <substitute>
104− <names variable="editor"/>
105− <names variable="translator"/>
106− <text macro="title"/>
107− </substitute>
108− </names>
109− </macro>
110− <macro name="interviewer">
111− <names variable="interviewer" delimiter=", ">
112− <label form="verb" prefix=" " text-case="capitalize-first" suffix=" "/>
113− <name and="text" delimiter=", "/>
114− </names>
115− </macro>
116− <macro name="archive">
117− <group delimiter=". ">
118− <text variable="archive_location" text-case="capitalize-first"/>
119− <text variable="archive"/>
120− <text variable="archive-place"/>
121− </group>
122− </macro>
123− <macro name="access">
124− <group delimiter=". ">
125− <choose>
126− <if type="graphic report" match="any">
127− <text macro="archive"/>
128− </if>
129− <else-if type="article-magazine article-newspaper bill book chapter graphic legal_case legislation motion_picture paper-conference report song thesis" match="none">
130− <text macro="archive"/>
131− </else-if>
132− </choose>
133− <text variable="DOI" prefix="doi:"/>
134− <choose>
135− <if variable="DOI issued" match="none">
136− <choose>
137− <if variable="URL accessed" match="all">
138− <group delimiter=" ">
139− <text term="accessed" text-case="capitalize-first"/>
140− <date variable="accessed" delimiter=" ">
141− <date-part name="month"/>
142− <date-part name="day"/>
143− </date>
144− </group>
145− </if>
146− </choose>
147− </if>
148− <else-if type="webpage">
149− <date variable="issued" delimiter=" ">
150− <date-part name="month"/>
151− <date-part name="day"/>
152− </date>
153− </else-if>
154− </choose>
155− <choose>
156− <if type="legal_case" match="none">
157− <text variable="URL"/>
158− </if>
159− </choose>
160− </group>
161− </macro>
162− <macro name="title">
163− <choose>
164− <if variable="title" match="none">
165− <choose>
166− <if type="personal_communication" match="none">
167− <text variable="genre" text-case="capitalize-first"/>
168− </if>
169− </choose>
170− </if>
171− <else-if type="bill book graphic legal_case legislation motion_picture song" match="any">
172− <text variable="title" text-case="title" font-style="italic"/>
173− </else-if>
174− <else>
175− <text variable="title" text-case="title" quotes="true"/>
176− </else>
177− </choose>
178− </macro>
179− <macro name="edition">
180− <choose>
181− <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
182− <choose>
183− <if is-numeric="edition">
184− <group delimiter=" " prefix=". ">
185− <number variable="edition" form="ordinal"/>
186− <text term="edition" form="short" strip-periods="true"/>
187− </group>
188− </if>
189− <else>
190− <text variable="edition" prefix=". "/>
191− </else>
192− </choose>
193− </if>
194− <else-if type="chapter paper-conference" match="any">
195− <choose>
196− <if is-numeric="edition">
197− <group delimiter=" " prefix=", ">
198− <number variable="edition" form="ordinal"/>
199− <text term="edition" form="short"/>
200− </group>
201− </if>
202− <else>
203− <text variable="edition" prefix=", "/>
204− </else>
205− </choose>
206− </else-if>
207− </choose>
208− </macro>
209− <macro name="locators">
210− <choose>
211− <if type="article-journal">
212− <text variable="volume" prefix=" "/>
213− <text variable="issue" prefix=" (" suffix=")"/>
214− </if>
215− <else-if type="legal_case">
216− <text variable="volume" prefix=", "/>
217− <text variable="container-title" prefix=" "/>
218− <text variable="page" prefix=" "/>
219− </else-if>
220− <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
221− <group prefix=". " delimiter=". ">
222− <group>
223− <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
224− <number variable="volume" form="numeric"/>
225− </group>
226− <group>
227− <number variable="number-of-volumes" form="numeric"/>
228− <text term="volume" form="short" prefix=" " plural="true"/>
229− </group>
230− </group>
231− </else-if>
232− <else-if type="chapter paper-conference" match="any">
233− <choose>
234− <if variable="page" match="none">
235− <group prefix=". ">
236− <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
237− <number variable="volume" form="numeric"/>
238− </group>
239− </if>
240− </choose>
241− </else-if>
242− </choose>
243− </macro>
244− <macro name="locators-chapter">
245− <choose>
246− <if type="chapter paper-conference" match="any">
247− <choose>
248− <if variable="page">
249− <group prefix=", ">
250− <text variable="volume" suffix=":"/>
251− <text variable="page"/>
252− </group>
253− </if>
254− </choose>
255− </if>
256− </choose>
257− </macro>
258− <macro name="locators-article">
259− <choose>
260− <if type="article-newspaper">
261− <group prefix=", " delimiter=", ">
262− <group>
263− <text variable="edition" suffix=" "/>
264− <text term="edition" prefix=" "/>
265− </group>
266− <group>
267− <text term="section" form="short" suffix=" "/>
268− <text variable="section"/>
269− </group>
270− </group>
271− </if>
272− <else-if type="article-journal">
273− <text variable="page" prefix=": "/>
274− </else-if>
275− </choose>
276− </macro>
277− <macro name="point-locators">
278− <choose>
279− <if variable="locator">
280− <choose>
281− <if locator="page" match="none">
282− <choose>
283− <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
284− <choose>
285− <if variable="volume">
286− <group>
287− <text term="volume" form="short" suffix=" "/>
288− <number variable="volume" form="numeric"/>
289− <label variable="locator" form="short" prefix=", " suffix=" "/>
290− </group>
291− </if>
292− <else>
293− <label variable="locator" form="short" suffix=" "/>
294− </else>
295− </choose>
296− </if>
297− <else>
298− <label variable="locator" form="short" suffix=" "/>
299− </else>
300− </choose>
301− </if>
302− <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
303− <number variable="volume" form="numeric" suffix=":"/>
304− </else-if>
305− </choose>
306− <text variable="locator"/>
307− </if>
308− </choose>
309− </macro>
310− <macro name="container-prefix">
311− <text term="in" text-case="capitalize-first"/>
312− </macro>
313− <macro name="container-title">
314− <choose>
315− <if type="chapter paper-conference" match="any">
316− <text macro="container-prefix" suffix=" "/>
317− </if>
318− </choose>
319− <choose>
320− <if type="legal_case" match="none">
321− <text variable="container-title" text-case="title" font-style="italic"/>
322− </if>
323− </choose>
324− </macro>
325− <macro name="publisher">
326− <group delimiter=": ">
327− <text variable="publisher-place"/>
328− <text variable="publisher"/>
329− </group>
330− </macro>
331− <macro name="date">
332− <choose>
333− <if variable="issued">
334− <date variable="issued">
335− <date-part name="year"/>
336− </date>
337− </if>
338− <else-if variable="accessed">
339− <date variable="accessed">
340− <date-part name="year"/>
341− </date>
342− </else-if>
343− </choose>
344− </macro>
345− <macro name="day-month">
346− <date variable="issued">
347− <date-part name="month"/>
348− <date-part name="day" prefix=" "/>
349− </date>
350− </macro>
351− <macro name="collection-title">
352− <text variable="collection-title" text-case="title"/>
353− <text variable="collection-number" prefix=" "/>
354− </macro>
355− <macro name="event">
356− <group>
357− <text term="presented at" suffix=" "/>
358− <text variable="event"/>
359− </group>
360− </macro>
361− <macro name="description">
362− <choose>
363− <if type="interview">
364− <group delimiter=". ">
365− <text macro="interviewer"/>
366− <text variable="medium" text-case="capitalize-first"/>
367− </group>
368− </if>
369− <else>
370− <text variable="medium" text-case="capitalize-first" prefix=". "/>
371− </else>
372− </choose>
373− <choose>
374− <if variable="title" match="none"/>
375− <else-if type="thesis"/>
376− <else>
377− <group delimiter=" " prefix=". ">
378− <text variable="genre" text-case="capitalize-first"/>
379− <choose>
380− <if type="report">
381− <text variable="number"/>
382− </if>
383− </choose>
384− </group>
385− </else>
386− </choose>
387− <!--This is for computer programs only. Localization new to 1.0.1, so may be missing in many locales-->
388− <group delimiter=" " prefix=" (" suffix=")">
389− <text term="version"/>
390− <text variable="version"/>
391− </group>
392− </macro>
393− <macro name="issue">
394− <choose>
395− <if type="article-journal">
396− <text macro="day-month" prefix=" (" suffix=")"/>
397− </if>
398− <else-if type="legal_case">
399− <text variable="authority" prefix=". "/>
400− </else-if>
401− <else-if type="speech">
402− <group prefix=" " delimiter=", ">
403− <text macro="event"/>
404− <text macro="day-month"/>
405− <text variable="event-place"/>
406− </group>
407− </else-if>
408− <else-if type="article-newspaper article-magazine" match="any">
409− <text macro="day-month" prefix=", "/>
410− </else-if>
411− <else>
412− <group prefix=". " delimiter=", ">
413− <choose>
414− <if type="thesis">
415− <text variable="genre" text-case="capitalize-first"/>
416− </if>
417− </choose>
418− <text macro="publisher"/>
419− </group>
420− </else>
421− </choose>
422− </macro>
423− <citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name">
424− <layout prefix="(" suffix=")" delimiter="; ">
425− <group delimiter=", ">
426− <group delimiter=" ">
427− <text macro="contributors-short"/>
428− <text macro="date"/>
429− </group>
430− <text macro="point-locators"/>
431− </group>
432− </layout>
433− </citation>
434− <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="&#8212;&#8212;&#8212;" entry-spacing="0">
435− <sort>
436− <key macro="contributors"/>
437− <key variable="issued"/>
438− </sort>
439− <layout suffix=".">
440− <group delimiter=". ">
441− <text macro="contributors"/>
442− <text macro="date"/>
443− <text macro="title"/>
444− </group>
445− <text macro="description"/>
446− <text macro="secondary-contributors" prefix=". "/>
447− <text macro="container-title" prefix=". "/>
448− <text macro="container-contributors"/>
449− <text macro="edition"/>
450− <text macro="locators-chapter"/>
451− <text macro="locators"/>
452− <text macro="collection-title" prefix=". "/>
453− <text macro="issue"/>
454− <text macro="locators-article"/>
455− <text macro="access" prefix=". "/>
456− </layout>
457− </bibliography>
458−</style>
pandoc.cabal+1−6
@@ -99,8 +99,6 @@ Data-Files:
9999 data/slideous/slideous.js,
100100 -- data for dzslides writer
101101 data/dzslides/template.html,
102− -- data for citeproc
103− data/default.csl,
104102 -- sample lua custom writer
105103 data/sample.lua
106104 -- documentation
@@ -250,7 +248,6 @@ Library
250248 xml >= 1.3.12 && < 1.4,
251249 random >= 1 && < 1.1,
252250 extensible-exceptions >= 0.1 && < 0.2,
253− citeproc-hs >= 0.3.7 && < 0.4,
254251 pandoc-types >= 1.12 && < 1.13,
255252 aeson >= 0.6 && < 0.7,
256253 tagsoup >= 0.12.5 && < 0.14,
@@ -323,7 +320,6 @@ Library
323320 Text.Pandoc.UTF8,
324321 Text.Pandoc.Templates,
325322 Text.Pandoc.XML,
326− Text.Pandoc.Biblio,
327323 Text.Pandoc.SelfContained,
328324 Text.Pandoc.Process
329325 Other-Modules: Text.Pandoc.Readers.Haddock.Lex,
@@ -353,8 +349,7 @@ Executable pandoc
353349 extensible-exceptions >= 0.1 && < 0.2,
354350 highlighting-kate >= 0.5.5 && < 0.6,
355351 aeson >= 0.6 && < 0.7,
356− HTTP >= 4000.0.5 && < 4000.3,
357− citeproc-hs >= 0.3.7 && < 0.4
352+ HTTP >= 4000.0.5 && < 4000.3
358353 Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
359354 Ghc-Prof-Options: -auto-all -caf-all -rtsopts -with-rtsopts=-K16m
360355 if os(windows)
pandoc.hs+3−65
@@ -35,7 +35,7 @@ import Text.Pandoc.PDF (makePDF)
3535import Text.Pandoc.Readers.LaTeX (handleIncludes)
3636import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile,
3737 safeRead, headerShift, normalize, err, warn )
38−import Text.Pandoc.XML ( toEntities, fromEntities )
38+import Text.Pandoc.XML ( toEntities )
3939import Text.Pandoc.SelfContained ( makeSelfContained )
4040import Text.Pandoc.Process (pipeProcess)
4141import Text.Highlighting.Kate ( languages, Style, tango, pygments,
@@ -46,20 +46,18 @@ import System.FilePath
4646import System.Console.GetOpt
4747import Data.Char ( toLower )
4848import Data.List ( intercalate, isPrefixOf, sort )
49−import System.Directory ( getAppUserDataDirectory, doesFileExist, findExecutable )
49+import System.Directory ( getAppUserDataDirectory, findExecutable )
5050import System.IO ( stdout, stderr )
5151import System.IO.Error ( isDoesNotExistError )
5252import qualified Control.Exception as E
5353import Control.Exception.Extensible ( throwIO )
5454import qualified Text.Pandoc.UTF8 as UTF8
55−import qualified Text.CSL as CSL
5655import Control.Monad (when, unless, liftM)
5756import Data.Foldable (foldrM)
5857import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
5958import Network.URI (parseURI, isURI, URI(..))
6059import qualified Data.ByteString.Lazy as B
6160import qualified Data.ByteString as BS
62−import Text.CSL.Reference (Reference(..))
6361import Data.Aeson (eitherDecode', encode)
6462
6563copyrightMessage :: String
@@ -70,7 +68,7 @@ copyrightMessage = "\nCopyright (C) 2006-2013 John MacFarlane\n" ++
7068
7169compileInfo :: String
7270compileInfo =
73− "\nCompiled with citeproc-hs " ++ VERSION_citeproc_hs ++ ", texmath " ++
71+ "\nCompiled with texmath " ++
7472 VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate ++
7573 ".\nSyntax highlighting is supported for the following languages:\n " ++
7674 wrapWords 4 78
@@ -146,9 +144,6 @@ data Opt = Opt
146144 , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks
147145 , optDataDir :: Maybe FilePath
148146 , optCiteMethod :: CiteMethod -- ^ Method to output cites
149− , optBibliography :: [String]
150− , optCslFile :: Maybe FilePath
151− , optAbbrevsFile :: Maybe FilePath
152147 , optListings :: Bool -- ^ Use listings package for code blocks
153148 , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf
154149 , optSlideLevel :: Maybe Int -- ^ Header level that creates slides
@@ -203,9 +198,6 @@ defaultOpts = Opt
203198 , optIndentedCodeClasses = []
204199 , optDataDir = Nothing
205200 , optCiteMethod = Citeproc
206− , optBibliography = []
207− , optCslFile = Nothing
208− , optAbbrevsFile = Nothing
209201 , optListings = False
210202 , optLaTeXEngine = "pdflatex"
211203 , optSlideLevel = Nothing
@@ -650,24 +642,6 @@ options =
650642 "PROGRAM")
651643 "" -- "Name of latex program to use in generating PDF"
652644
653− , Option "" ["bibliography"]
654− (ReqArg
655− (\arg opt -> return opt { optBibliography = (optBibliography opt) ++ [arg] })
656− "FILENAME")
657− ""
658−
659− , Option "" ["csl"]
660− (ReqArg
661− (\arg opt -> return opt { optCslFile = Just arg })
662− "FILENAME")
663− ""
664−
665− , Option "" ["citation-abbreviations"]
666− (ReqArg
667− (\arg opt -> return opt { optAbbrevsFile = Just arg })
668− "FILENAME")
669− ""
670−
671645 , Option "" ["natbib"]
672646 (NoArg
673647 (\opt -> return opt { optCiteMethod = Natbib }))
@@ -904,9 +878,6 @@ main = do
904878 , optIdentifierPrefix = idPrefix
905879 , optIndentedCodeClasses = codeBlockClasses
906880 , optDataDir = mbDataDir
907− , optBibliography = reffiles
908− , optCslFile = mbCsl
909− , optAbbrevsFile = cslabbrevs
910881 , optCiteMethod = citeMethod
911882 , optListings = listings
912883 , optLaTeXEngine = latexEngine
@@ -1007,36 +978,6 @@ main = do
1007978 $ lines dztempl
1008979 return $ ("dzslides-core", dzcore) : variables'
1009980 else return variables'
1010−
1011− -- unescape reference ids, which may contain XML entities, so
1012− -- that we can do lookups with regular string equality
1013− let unescapeRefId ref = ref{ refId = fromEntities (refId ref) }
1014−
1015− refs <- mapM (\f -> E.catch (CSL.readBiblioFile f)
1016− (\e -> let _ = (e :: E.SomeException)
1017− in err 23 $ "Error reading bibliography `" ++ f ++
1018− "'" ++ "\n" ++ show e))
1019− reffiles >>=
1020− return . map unescapeRefId . concat
1021−
1022− mbsty <- if citeMethod == Citeproc && not (null refs)
1023− then do
1024− csl <- CSL.parseCSL =<<
1025− case mbCsl of
1026− Nothing -> readDataFileUTF8 datadir
1027− "default.csl"
1028− Just cslfile -> do
1029− exists <- doesFileExist cslfile
1030− if exists
1031− then UTF8.readFile cslfile
1032− else do
1033− csldir <- getAppUserDataDirectory "csl"
1034− readDataFileUTF8 (Just csldir)
1035− (replaceExtension cslfile "csl")
1036− abbrevs <- maybe (return []) CSL.readJsonAbbrevFile cslabbrevs
1037− return $ Just csl { CSL.styleAbbrevs = abbrevs }
1038− else return Nothing
1039−
1040981 let sourceURL = case sources of
1041982 [] -> Nothing
1042983 (x:_) -> case parseURI x of
@@ -1054,8 +995,6 @@ main = do
1054995 , readerColumns = columns
1055996 , readerTabStop = tabStop
1056997 , readerOldDashes = oldDashes
1057− , readerReferences = refs
1058− , readerCitationStyle = mbsty
1059998 , readerIndentedCodeClasses = codeBlockClasses
1060999 , readerApplyMacros = not laTeXOutput
10611000 , readerDefaultImageExtension = defaultImageExtension
@@ -1069,7 +1008,6 @@ main = do
10691008 writerHTMLMathMethod = mathMethod,
10701009 writerIncremental = incremental,
10711010 writerCiteMethod = citeMethod,
1072− writerBiblioFiles = reffiles,
10731011 writerIgnoreNotes = False,
10741012 writerNumberSections = numberSections,
10751013 writerNumberOffset = numberFrom,
src/Text/Pandoc/Biblio.hsdeleted−216
@@ -1,216 +0,0 @@
1−{-# LANGUAGE PatternGuards #-}
2−{-
3−Copyright (C) 2008 Andrea Rossato <andrea.rossato@ing.unitn.it>
4−
5−This program is free software; you can redistribute it and/or modify
6−it under the terms of the GNU General Public License as published by
7−the Free Software Foundation; either version 2 of the License, or
8−(at your option) any later version.
9−
10−This program is distributed in the hope that it will be useful,
11−but WITHOUT ANY WARRANTY; without even the implied warranty of
12−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13−GNU General Public License for more details.
14−
15−You should have received a copy of the GNU General Public License
16−along with this program; if not, write to the Free Software
17−Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18−-}
19−
20−{- |
21− Module : Text.Pandoc.Biblio
22− Copyright : Copyright (C) 2008-2010 Andrea Rossato
23− License : GNU GPL, version 2 or above
24−
25− Maintainer : Andrea Rossato <andrea.rossato@unitn.it>
26− Stability : alpha
27− Portability : portable
28−-}
29−
30−module Text.Pandoc.Biblio ( processBiblio ) where
31−
32−import Data.List
33−import Data.Char ( isDigit, isPunctuation )
34−import qualified Data.Map as M
35−import Text.CSL hiding ( Cite(..), Citation(..), endWithPunct )
36−import qualified Text.CSL as CSL ( Cite(..) )
37−import Text.Pandoc.Definition
38−import Text.Pandoc.Generic
39−import Text.Pandoc.Walk
40−import Text.Pandoc.Shared (stringify)
41−import Text.Parsec hiding (State)
42−import Control.Monad
43−import Control.Monad.State
44−
45−-- | Process a 'Pandoc' document by adding citations formatted
46−-- according to a CSL style, using 'citeproc' from citeproc-hs.
47−processBiblio :: Maybe Style -> [Reference] -> Pandoc -> Pandoc
48−processBiblio Nothing _ p = p
49−processBiblio _ [] p = p
50−processBiblio (Just style) r p =
51− let p' = evalState (bottomUpM setHash p) 1
52− grps = query getCitation p'
53− result = citeproc procOpts style r (setNearNote style $
54− map (map toCslCite) grps)
55− cits_map = M.fromList $ zip grps (citations result)
56− biblioList = map (renderPandoc' style) (bibliography result)
57− Pandoc m b = bottomUp mvPunct . deNote . topDown (processCite style cits_map) $ p'
58− (bs, lastb) = case reverse b of
59− x@(Header _ _ _) : xs -> (reverse xs, [x])
60− _ -> (b, [])
61− in Pandoc m $ bs ++ [Div ("",["references"],[]) (lastb ++ biblioList)]
62−
63−-- | Substitute 'Cite' elements with formatted citations.
64−processCite :: Style -> M.Map [Citation] [FormattedOutput] -> Inline -> Inline
65−processCite s cs (Cite t _) =
66− case M.lookup t cs of
67− Just (x:xs)
68− | isTextualCitation t && not (null xs) ->
69− let xs' = renderPandoc s xs
70− in if styleClass s == "note"
71− then Cite t (renderPandoc s [x] ++ [Note [Para xs']])
72− else Cite t (renderPandoc s [x] ++ [Space | not (startWithPunct xs')] ++ xs')
73− | otherwise -> if styleClass s == "note"
74− then Cite t [Note [Para $ renderPandoc s (x:xs)]]
75− else Cite t (renderPandoc s (x:xs))
76− _ -> Strong [Str "???"] -- TODO raise error instead?
77−processCite _ _ x = x
78−
79−isNote :: Inline -> Bool
80−isNote (Note _) = True
81−isNote (Cite _ [Note _]) = True
82−isNote _ = False
83−
84−mvPunct :: [Inline] -> [Inline]
85−mvPunct (Space : Space : xs) = Space : xs
86−mvPunct (Space : x : ys) | isNote x, startWithPunct ys =
87− Str (headInline ys) : x : tailFirstInlineStr ys
88−mvPunct (Space : x : ys) | isNote x = x : ys
89−mvPunct xs = xs
90−
91−-- A replacement for citeproc-hs's endWithPunct, which wrongly treats
92−-- a sentence ending in '.)' as not ending with punctuation, leading
93−-- to an extra period.
94−endWithPunct :: [Inline] -> Bool
95−endWithPunct [] = True
96−endWithPunct xs@(_:_) = case reverse (stringify [last xs]) of
97− [] -> True
98− (')':c:_) | isEndPunct c -> True
99− (c:_) | isEndPunct c -> True
100− | otherwise -> False
101− where isEndPunct c = c `elem` ".,;:!?"
102−
103−deNote :: Pandoc -> Pandoc
104−deNote = topDown go
105− where go (Cite (c:cs) [Note xs]) =
106− Cite (c:cs) [Note $ bottomUp go' $ sanitize c xs]
107− go (Note xs) = Note $ bottomUp go' xs
108− go x = x
109− go' (Note [Para xs]:ys) =
110− if startWithPunct ys && endWithPunct xs
111− then initInline xs ++ ys
112− else xs ++ ys
113− go' xs = xs
114− sanitize :: Citation -> [Block] -> [Block]
115− sanitize Citation{citationPrefix = pref} [Para xs] =
116− case (null pref, endWithPunct xs) of
117− (True, False) -> [Para $ xs ++ [Str "."]]
118− (True, True) -> [Para xs]
119− (False, False) -> [Para $ toCapital $ xs ++ [Str "."]]
120− (False, True) -> [Para $ toCapital xs]
121− sanitize _ bs = bs
122−
123−isTextualCitation :: [Citation] -> Bool
124−isTextualCitation (c:_) = citationMode c == AuthorInText
125−isTextualCitation _ = False
126−
127−-- | Retrieve all citations from a 'Pandoc' docuument. To be used with
128−-- 'query'.
129−getCitation :: Inline -> [[Citation]]
130−getCitation i | Cite t _ <- i = [t]
131− | otherwise = []
132−
133−setHash :: Citation -> State Int Citation
134−setHash c = do
135− ident <- get
136− put $ ident + 1
137− return c{ citationHash = ident }
138−
139−toCslCite :: Citation -> CSL.Cite
140−toCslCite c
141− = let (l, s) = locatorWords $ citationSuffix c
142− (la,lo) = parseLocator l
143− s' = case (l,s) of
144− -- treat a bare locator as if it begins with space
145− -- so @item1 [blah] is like [@item1, blah]
146− ("",(x:_))
147− | not (isPunct x) -> [Space] ++ s
148− _ -> s
149− isPunct (Str (x:_)) = isPunctuation x
150− isPunct _ = False
151− citMode = case citationMode c of
152− AuthorInText -> (True, False)
153− SuppressAuthor -> (False,True )
154− NormalCitation -> (False,False)
155− in emptyCite { CSL.citeId = citationId c
156− , CSL.citePrefix = PandocText $ citationPrefix c
157− , CSL.citeSuffix = PandocText s'
158− , CSL.citeLabel = la
159− , CSL.citeLocator = lo
160− , CSL.citeNoteNumber = show $ citationNoteNum c
161− , CSL.authorInText = fst citMode
162− , CSL.suppressAuthor = snd citMode
163− , CSL.citeHash = citationHash c
164− }
165−
166−locatorWords :: [Inline] -> (String, [Inline])
167−locatorWords inp =
168− case parse pLocatorWords "suffix" $ breakup inp of
169− Right r -> r
170− Left _ -> ("",inp)
171− where breakup [] = []
172− breakup (Str x : xs) = map Str (splitup x) ++ breakup xs
173− breakup (x : xs) = x : breakup xs
174− splitup = groupBy (\x y -> x /= '\160' && y /= '\160')
175−
176−pLocatorWords :: Parsec [Inline] st (String, [Inline])
177−pLocatorWords = do
178− l <- pLocator
179− s <- getInput -- rest is suffix
180− if length l > 0 && last l == ','
181− then return (init l, Str "," : s)
182− else return (l, s)
183−
184−pMatch :: (Inline -> Bool) -> Parsec [Inline] st Inline
185−pMatch condition = try $ do
186− t <- anyToken
187− guard $ condition t
188− return t
189−
190−pSpace :: Parsec [Inline] st Inline
191−pSpace = pMatch (\t -> t == Space || t == Str "\160")
192−
193−pLocator :: Parsec [Inline] st String
194−pLocator = try $ do
195− optional $ pMatch (== Str ",")
196− optional pSpace
197− f <- (guardFollowingDigit >> return [Str "p"]) -- "page" the default
198− <|> many1 (notFollowedBy pSpace >> anyToken)
199− gs <- many1 pWordWithDigits
200− return $ stringify f ++ (' ' : unwords gs)
201−
202−guardFollowingDigit :: Parsec [Inline] st ()
203−guardFollowingDigit = do
204− t <- lookAhead anyToken
205− case t of
206− Str (d:_) | isDigit d -> return ()
207− _ -> mzero
208−
209−pWordWithDigits :: Parsec [Inline] st String
210−pWordWithDigits = try $ do
211− optional pSpace
212− r <- many1 (notFollowedBy pSpace >> anyToken)
213− let s = stringify r
214− guard $ any isDigit s
215− return s
216−
src/Text/Pandoc/Options.hs−7
@@ -48,7 +48,6 @@ import Data.Set (Set)
4848import qualified Data.Set as Set
4949import Data.Default
5050import Text.Pandoc.Highlighting (Style, pygments)
51−import qualified Text.CSL as CSL
5251
5352-- | Individually selectable syntax extensions.
5453data Extension =
@@ -205,8 +204,6 @@ data ReaderOptions = ReaderOptions{
205204 , readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior
206205 -- in parsing dashes; -- is em-dash;
207206 -- - before numerial is en-dash
208− , readerReferences :: [CSL.Reference] -- ^ Bibliographic references
209− , readerCitationStyle :: Maybe CSL.Style -- ^ Citation style
210207 , readerApplyMacros :: Bool -- ^ Apply macros to TeX math
211208 , readerIndentedCodeClasses :: [String] -- ^ Default classes for
212209 -- indented code blocks
@@ -223,8 +220,6 @@ instance Default ReaderOptions
223220 , readerColumns = 80
224221 , readerTabStop = 4
225222 , readerOldDashes = False
226− , readerReferences = []
227− , readerCitationStyle = Nothing
228223 , readerApplyMacros = True
229224 , readerIndentedCodeClasses = []
230225 , readerDefaultImageExtension = ""
@@ -289,7 +284,6 @@ data WriterOptions = WriterOptions
289284 , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
290285 , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
291286 , writerCiteMethod :: CiteMethod -- ^ How to print cites
292− , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations
293287 , writerHtml5 :: Bool -- ^ Produce HTML5
294288 , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
295289 , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
@@ -332,7 +326,6 @@ instance Default WriterOptions where
332326 , writerSourceURL = Nothing
333327 , writerUserDataDir = Nothing
334328 , writerCiteMethod = Citeproc
335− , writerBiblioFiles = []
336329 , writerHtml5 = False
337330 , writerHtmlQTags = False
338331 , writerBeamer = False
src/Text/Pandoc/Readers/LaTeX.hs+1−4
@@ -38,7 +38,6 @@ import Text.Pandoc.Definition
3838import Text.Pandoc.Walk
3939import Text.Pandoc.Shared
4040import Text.Pandoc.Options
41−import Text.Pandoc.Biblio (processBiblio)
4241import Text.Pandoc.Parsing hiding ((<|>), many, optional, space)
4342import qualified Text.Pandoc.UTF8 as UTF8
4443import Data.Char ( chr, ord )
@@ -67,9 +66,7 @@ parseLaTeX = do
6766 eof
6867 st <- getState
6968 let meta = stateMeta st
70− refs <- getOption readerReferences
71− mbsty <- getOption readerCitationStyle
72− let (Pandoc _ bs') = processBiblio mbsty refs $ doc bs
69+ let (Pandoc _ bs') = doc bs
7370 return $ Pandoc meta bs'
7471
7572type LP = Parser [Char] ParserState
src/Text/Pandoc/Readers/Markdown.hs+1−4
@@ -54,7 +54,6 @@ import Text.Pandoc.Parsing hiding (tableWith)
5454import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
5555import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag,
5656 isTextTag, isCommentTag )
57−import Text.Pandoc.Biblio (processBiblio)
5857import Data.Monoid (mconcat, mempty)
5958import Control.Applicative ((<$>), (<*), (*>), (<$))
6059import Control.Monad
@@ -327,9 +326,7 @@ parseMarkdown = do
327326 st <- getState
328327 let meta = runF (stateMeta' st) st
329328 let Pandoc _ bs = B.doc $ runF blocks st
330− mbsty <- getOption readerCitationStyle
331− refs <- getOption readerReferences
332− return $ processBiblio mbsty refs $ Pandoc meta bs
329+ return $ Pandoc meta bs
333330
334331addWarning :: Maybe SourcePos -> String -> MarkdownParser ()
335332addWarning mbpos msg =
src/Text/Pandoc/Writers/LaTeX.hs+2−6
@@ -43,7 +43,6 @@ import Data.Char ( toLower, isPunctuation )
4343import Control.Applicative ((<|>))
4444import Control.Monad.State
4545import Text.Pandoc.Pretty
46−import System.FilePath (dropExtension)
4746import Text.Pandoc.Slides
4847import Text.Pandoc.Highlighting (highlight, styleToLaTeX,
4948 formatLaTeXInline, formatLaTeXBlock,
@@ -120,7 +119,6 @@ pandocToLaTeX options (Pandoc meta blocks) = do
120119 (biblioTitle :: String) <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
121120 let main = render colwidth $ vsep body
122121 st <- get
123− let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options
124122 let context = defField "toc" (writerTableOfContents options) $
125123 defField "toc-depth" (show (writerTOCDepth options -
126124 if writerChapters options
@@ -152,11 +150,9 @@ pandocToLaTeX options (Pandoc meta blocks) = do
152150 $ writerHighlightStyle options )
153151 else id) $
154152 (case writerCiteMethod options of
155− Natbib -> defField "biblio-files" biblioFiles .
156− defField "biblio-title" biblioTitle .
153+ Natbib -> defField "biblio-title" biblioTitle .
157154 defField "natbib" True
158− Biblatex -> defField "biblio-files" biblioFiles .
159− defField "biblio-title" biblioTitle .
155+ Biblatex -> defField "biblio-title" biblioTitle .
160156 defField "biblatex" True
161157 _ -> id) $
162158 metadata
tests/Tests/Old.hs−14
@@ -63,7 +63,6 @@ tests = [ testGroup "markdown"
6363 "markdown-reader-more.txt" "markdown-reader-more.native"
6464 , lhsReaderTest "markdown+lhs"
6565 ]
66− , testGroup "citations" markdownCitationTests
6766 ]
6867 , testGroup "rst"
6968 [ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst")
@@ -190,19 +189,6 @@ fb2WriterTest title opts inputfile normfile =
190189 ignoreBinary = unlines . filter (not . startsWith "<binary ") . lines
191190 startsWith tag str = all (uncurry (==)) $ zip tag str
192191
193−markdownCitationTests :: [Test]
194−markdownCitationTests
195− = map styleToTest ["chicago-author-date","ieee","mhra"]
196− ++ [test "natbib" wopts "markdown-citations.txt"
197− "markdown-citations.txt"]
198− where
199− ropts = ["-r", "markdown", "-w", "markdown-citations", "--bibliography",
200− "biblio.bib", "--no-wrap"]
201− wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"]
202− styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
203− "markdown-citations.txt"
204− ("markdown-citations." ++ style ++ ".txt")
205−
206192-- | Run a test without normalize function, return True if test passed.
207193test :: String -- ^ Title of test
208194 -> [String] -- ^ Options to pass to pandoc