summaryrefslogtreecommitdiff
path: root/paper/lua-filters/bibexport
diff options
context:
space:
mode:
Diffstat (limited to 'paper/lua-filters/bibexport')
-rw-r--r--paper/lua-filters/bibexport/Makefile5
-rw-r--r--paper/lua-filters/bibexport/README.md31
-rw-r--r--paper/lua-filters/bibexport/bibexport.lua82
-rw-r--r--paper/lua-filters/bibexport/coffee.bib48
-rw-r--r--paper/lua-filters/bibexport/expected.bibexport.aux3
-rw-r--r--paper/lua-filters/bibexport/expected.bibexport.bib27
-rw-r--r--paper/lua-filters/bibexport/sample.bib13
-rw-r--r--paper/lua-filters/bibexport/sample.md18
8 files changed, 0 insertions, 227 deletions
diff --git a/paper/lua-filters/bibexport/Makefile b/paper/lua-filters/bibexport/Makefile
deleted file mode 100644
index 67081b0..0000000
--- a/paper/lua-filters/bibexport/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-test:
- @pandoc --lua-filter=bibexport.lua sample.md > /dev/null
- @diff --strip-trailing-cr -u bibexport.aux expected.bibexport.aux
- @diff --strip-trailing-cr -u bibexport.bib expected.bibexport.bib
- @rm -f bibexport.aux bibexport.bib
diff --git a/paper/lua-filters/bibexport/README.md b/paper/lua-filters/bibexport/README.md
deleted file mode 100644
index ea1b54d..0000000
--- a/paper/lua-filters/bibexport/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-# bibexport
-
-Export all cited references into a single bibtex file. This is
-most useful when writing collaboratively while using a large,
-private bibtex collection. Using the bibexport filter allows to
-create a reduced bibtex file suitable for sharing with
-collaborators.
-
-## Prerequisites
-
-This filter expects the `bibexport` executable to be installed
-and in the user's PATH.
-
-## Usage
-
-The filter runs `bibexport` on a temporary *aux* file, creating
-the file *bibexport.bib* on success. The name of the temporary
-*.aux* file can be set via the `auxfile` meta value; if no value
-is specified, *bibexport.aux* will be used as filename.
-
-Please note that `bibexport` prints messages to stdout. Pandoc
-should be called with the `-o` or `--output` option instead of
-redirecting stdout to a file. E.g.
-
- pandoc --lua-filter=bibexport.lua article.md -o article.html
-
-or, when the filter is called in a one-off fashion
-
- pandoc --lua-filter=bibexport.lua article.md -o /dev/null
-
-
diff --git a/paper/lua-filters/bibexport/bibexport.lua b/paper/lua-filters/bibexport/bibexport.lua
deleted file mode 100644
index 9174e69..0000000
--- a/paper/lua-filters/bibexport/bibexport.lua
+++ /dev/null
@@ -1,82 +0,0 @@
-local utils = require 'pandoc.utils'
-local List = require 'pandoc.List'
-
-local citation_id_set = {}
-
--- Collect all citation IDs.
-function Cite (c)
- local cs = c.citations
- for i = 1, #cs do
- citation_id_set[cs[i].id or cs[i].citationId] = true
- end
-end
-
---- Return a list of citation IDs
-function citation_ids ()
- local citations = {};
- for cid, _ in pairs(citation_id_set) do
- citations[#citations + 1] = cid
- end
- return citations
-end
-
-function bibdata (bibliography)
- function bibname (bibitem)
- if type(bibitem) == 'string' then
- return bibitem:gsub('%.bib$', '')
- else
- -- bibitem is assumed to be a list of inlines
- return utils.stringify(pandoc.Span(bibitem)):gsub('%.bib$', '')
- end
- end
-
- local bibs = bibliography.t == 'MetaList'
- and List.map(bibliography, bibname)
- or {bibname(bibliography)}
- return table.concat(bibs, ',')
-end
-
-function aux_content(bibliography)
- local cites = citation_ids()
- table.sort(cites)
- local citations = table.concat(cites, ',')
- return table.concat(
- {
- '\\bibstyle{alpha}',
- '\\bibdata{' .. bibdata(bibliography) .. '}',
- '\\citation{' .. citations .. '}',
- '',
- },
- '\n'
- )
-end
-
-function write_dummy_aux (bibliography, auxfile)
- local filename
- if type(auxfile) == 'string' then
- filename = auxfile
- elseif type(auxfile) == 'table' then
- -- assume list of inlines
- filename = utils.stringify(pandoc.Span(auxfile))
- else
- filename = 'bibexport.aux'
- end
- local fh = io.open(filename, 'w')
- fh:write(aux_content(bibliography))
- fh:close()
- io.stdout:write('Aux written to ' .. filename .. '\n')
- return filename
-end
-
-function Pandoc (doc)
- local meta = doc.meta
- if not meta.bibliography then
- return nil
- else
- -- create a dummy .aux file
- local auxfile_name = write_dummy_aux(meta.bibliography, meta.auxfile)
- os.execute('bibexport ' .. auxfile_name)
- io.stdout:write('Output written to bibexport.bib\n')
- return nil
- end
-end
diff --git a/paper/lua-filters/bibexport/coffee.bib b/paper/lua-filters/bibexport/coffee.bib
deleted file mode 100644
index 80b723c..0000000
--- a/paper/lua-filters/bibexport/coffee.bib
+++ /dev/null
@@ -1,48 +0,0 @@
-@article{BrSm02,
- author = {C. F. Brice and A. P. Smith},
- title = {Effects of caffeine on mood and performance: a study on
- realistic consumption},
- journal = {Psychopharmacology (Berlin)},
- year = 2002,
- volume = 164,
- pages = {188--192}
-}
-
-@article{LoSnMuKo95,
- author = {M. M. Lorist and J. Snel and G. Mulder and A. Kok},
- title = {Aging, caffeine, and information processing: an
- event-related potential analysis},
- journal = {Electroencephalogr Clin Neurophysiol},
- year = 1995,
- volume = 96,
- pages = {453--467}
-}
-
-@article{Li95,
- author = {L. Linde},
- title = {Mental effects of caffeine in fatigued and non-fatigued
- female and male subjects},
- journal = {Ergonomics},
- year = 1995,
- volume = 38,
- pages = {864--885}
-}
-
-@article{KjOs07,
- author = {Dannie Kjeldgaard and Jacob Ostberg},
- title = {Coffee grounds and the global cup: glocal consumer culture
- in scandinavia},
- journal = {Consumption, Markets and Culture},
- year = 2007,
- pages = {175--187},
- volume = 10,
- issue = 2
-}
-
-@book{De92,
- author = {G Debry},
- title = {Coffee and Health: Composition, Consumption and Effect upon Health},
- publisher = {John Libbey Eurotext},
- year = 1992,
- ISBN = {2-7420-0037-2}
-}
diff --git a/paper/lua-filters/bibexport/expected.bibexport.aux b/paper/lua-filters/bibexport/expected.bibexport.aux
deleted file mode 100644
index d5f3144..0000000
--- a/paper/lua-filters/bibexport/expected.bibexport.aux
+++ /dev/null
@@ -1,3 +0,0 @@
-\bibstyle{alpha}
-\bibdata{sample,coffee}
-\citation{Li95,Upper_writers_1974}
diff --git a/paper/lua-filters/bibexport/expected.bibexport.bib b/paper/lua-filters/bibexport/expected.bibexport.bib
deleted file mode 100644
index 57448ed..0000000
--- a/paper/lua-filters/bibexport/expected.bibexport.bib
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-@article{Li95,
- author = {L. Linde},
- journal = {Ergonomics},
- pages = {864--885},
- title = {Mental effects of caffeine in fatigued and
- non-fatigued female and male subjects},
- volume = {38},
- year = {1995},
-}
-
-@article{Upper_writers_1974,
- author = {Upper, Dennis},
- journal = {Journal of Applied Behavior Analysis},
- number = {3},
- pages = {497--497},
- publisher = {Blackwell Publishing Ltd},
- title = {The unsuccessful self-treatment of a case of
- “writer's block”},
- volume = {7},
- year = {1974},
- doi = {10.1901/jaba.1974.7-497a},
- issn = {1938-3703},
- url = {http://dx.doi.org/10.1901/jaba.1974.7-497a},
-}
-
diff --git a/paper/lua-filters/bibexport/sample.bib b/paper/lua-filters/bibexport/sample.bib
deleted file mode 100644
index 876eea1..0000000
--- a/paper/lua-filters/bibexport/sample.bib
+++ /dev/null
@@ -1,13 +0,0 @@
-@article {Upper_writers_1974,
- author = {Upper, Dennis},
- title = {The unsuccessful self-treatment of a case of “writer's block”},
- journal = {Journal of Applied Behavior Analysis},
- volume = {7},
- number = {3},
- publisher = {Blackwell Publishing Ltd},
- issn = {1938-3703},
- url = {http://dx.doi.org/10.1901/jaba.1974.7-497a},
- doi = {10.1901/jaba.1974.7-497a},
- pages = {497--497},
- year = {1974},
-}
diff --git a/paper/lua-filters/bibexport/sample.md b/paper/lua-filters/bibexport/sample.md
deleted file mode 100644
index d458b37..0000000
--- a/paper/lua-filters/bibexport/sample.md
+++ /dev/null
@@ -1,18 +0,0 @@
----
-bibliography:
-- sample.bib
-- coffee.bib
-...
-
-# Abstract
-
-This is an example article. It was written under the influence of
-coffee, which acts to counter fatigue [@Li95].
-
-
-# Further reading
-
-Authors struggling to fill their document with content are referred to
-@Upper_writers_1974.
-
-# References