summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-02-06 19:13:34 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2022-02-06 19:13:34 -0800
commit2b3433404ebdf5bd8c4a4030965ca7cda74e4c29 (patch)
tree91c6a1d270d286f33a32395e91c0f036c7d7b8a5 /doc
parent0f0b042139e3a82673590f14b70e5fcb5e57ea61 (diff)
Remove sample RIS custom reader (since we now have a native one).
Diffstat (limited to 'doc')
-rw-r--r--doc/custom-readers.md217
1 files changed, 0 insertions, 217 deletions
diff --git a/doc/custom-readers.md b/doc/custom-readers.md
index 08ee7e889..add2317a2 100644
--- a/doc/custom-readers.md
+++ b/doc/custom-readers.md
@@ -159,223 +159,6 @@ except paragraph breaks.
]
```
-# Example: a RIS bibliography reader
-
-This is a parser for [RIS bibliography] files. It can be used
-to convert them to CSL JSON or YAML, BibTeX, or BibLaTeX.
-
-[RIS bibliography]: https://en.wikipedia.org/wiki/RIS_(file_format)
-
-```lua
--- A sample custom reader for RIS bibliography format
--- https://en.wikipedia.org/wiki/RIS_(file_format)
--- The references are converted to inline pandoc/CSL YAML
--- references in the metadata.
-
-local inspect = require"inspect"
-
-local types =
- { ABST = "article",
- ADVS = "motion-picture",
- AGGR = "dataset",
- ANCIENT = "book",
- ART = "graphic",
- BILL = "bill",
- BLOG = "post-weblog",
- BOOK = "book",
- CASE = "legal_case",
- CHAP = "chapter",
- CHART = "graphic",
- CLSWK = "book",
- COMP = "program",
- CONF = "paper-conference",
- CPAPER = "paper-conference",
- CTLG = "catalog",
- DATA = "dataset",
- DBASE = "dataset",
- DICT = "book",
- EBOOK = "book",
- ECHAP = "chapter",
- EDBOOK = "book",
- EJOUR = "article",
- WEB = "webpage",
- ENCYC = "entry-encyclopedia",
- EQUA = "figure",
- FIGURE = "figure",
- GEN = "entry",
- GOVDOC = "report",
- GRANT = "report",
- HEAR = "report",
- ICOMM = "personal_communication",
- INPR = "article-journal",
- JFULL = "article-journal",
- JOUR = "article-journal",
- LEGAL = "legal_case",
- MANSCPT = "manuscript",
- MAP = "map",
- MGZN = "article-magazine",
- MPCT = "motion-picture",
- MULTI = "webpage",
- MUSIC = "musical_score",
- NEWS = "article-newspaper",
- PAMP = "pamphlet",
- PAT = "patent",
- PCOMM = "personal_communication",
- RPRT = "report",
- SER = "article",
- SLIDE = "graphic",
- SOUND = "musical_score",
- STAND = "report",
- STAT = "legislation",
- THES = "thesis",
- UNBILL = "bill",
- UNPB = "unpublished",
- VIDEO = "graphic"
- }
-
-local function clean(refpairs)
- local ref = {}
- for i = 1, #refpairs do
- local k,v = table.unpack(refpairs[i])
- if k == "TY" then
- ref["type"] = types[v]
- elseif k == "VL" then
- ref.volume = v
- elseif k == "KW" then
- ref.keyword = v
- elseif k == "PB" then
- ref.publisher = v
- elseif k == "CY" or k == "PP" then
- ref["publisher-place"] = v
- elseif k == "SP" then
- if ref.page then
- ref.page = v .. ref.page
- else
- ref.page = v
- end
- elseif k == "EP" then
- if ref.page then
- ref.page = ref.page .. "-" .. v
- else
- ref.page = "-" .. v
- end
- elseif k == "AU" or k == "A1" or k == "A2" or k == "A3" then
- if ref.author then
- table.insert(ref.author, v)
- else
- ref.author = {v}
- end
- elseif k == "TI" or k == "T1" or k == "CT" or
- (k == "BT" and ref.type == "book") then
- ref.title = v
- elseif k == "ET" then
- ref.edition = v
- elseif k == "NV" then
- ref["number-of-volumes"] = v
- elseif k == "AB" then
- ref.abstract = v
- elseif k == "ED" then
- if ref.editor then
- table.insert(ref.editor, v)
- else
- ref.editor = {v}
- end
- elseif k == "JO" or k == "JF" or k == "T2" or
- (k == "BT" and ref.type ~= "book") then
- ref["container-title"] = v
- elseif k == "PY" or k == "Y1" then
- ref.issued = v
- elseif k == "IS" then
- ref.issue = v
- elseif k == "SN" then
- ref.ISSN = v
- elseif k == "L" then
- ref.lang = v
- elseif k == "UR" or k == "LK" then
- ref.URL = v
- end
- end
- return ref
-end
-
-function Reader(input, reader_options)
- local refs = {}
- local thisref = {}
- local ids = {}
- for line in string.gmatch(tostring(input), "[^\n]*") do
- key, val = string.match(line, "([A-Z][A-Z0-9]) %- (.*)")
- if key == "ER" then
- -- clean up fields
- local newref = clean(thisref)
- -- ensure we have an id and if not, create a sensible one
- if not newref.id then
- newref.id = ""
- for _,x in ipairs(newref.author) do
- newref.id = newref.id .. string.match(pandoc.utils.stringify(x), "%a+")
- end
- if newref.issued then
- newref.id = newref.id .. string.match(newref.issued, "%d+")
- end
- if ids[newref.id] then -- add disambiguator if needed
- newref.id = newref.id .. "-" .. #ids
- end
- end
- table.insert(ids, newref.id)
- table.insert(refs, newref)
- thisref = {}
- elseif key then
- table.insert(thisref, {key, val})
- end
- end
- return pandoc.Pandoc({}, pandoc.Meta { references = refs } )
-end
-```
-
-Example of use:
-
-```
-% pandoc -f ris.lua -t bibtex
-TY - JOUR
-AU - Shannon, Claude E.
-PY - 1948
-DA - July
-TI - A Mathematical Theory of Communication
-T2 - Bell System Technical Journal
-SP - 379
-EP - 423
-VL - 27
-ER -
-TY - JOUR
-T1 - On computable numbers, with an application to the Entscheidungsproblem
-A1 - Turing, Alan Mathison
-JO - Proc. of London Mathematical Society
-VL - 47
-IS - 1
-SP - 230
-EP - 265
-Y1 - 1937
-ER -
-^D
-@article{Shannon1948,
- author = {Shannon, Claude E.},
- title = {A {Mathematical} {Theory} of {Communication}},
- journal = {Bell System Technical Journal},
- volume = {27},
- pages = {379-423},
- year = {1948}
-}
-@article{Turing1937,
- author = {Turing, Alan Mathison},
- title = {On Computable Numbers, with an Application to the
- {Entscheidungsproblem}},
- journal = {Proc. of London Mathematical Society},
- volume = {47},
- number = {1},
- pages = {230-265},
- year = {1937}
-}
-```
-
# Example: a wiki Creole reader
This is a parser for [Creole common wiki markup].