nichtich / ideas

Public ideas collected as GitHub issues
Creative Commons Zero v1.0 Universal
1 stars 0 forks source link

Document toolchain to use Wikidata as CSL-Data backend #13

Open nichtich opened 6 years ago

nichtich commented 6 years ago

Similar to scholia.tex Python script but more versatile because citation key extraction is done by pandoc and extraction of bibliographic data from Wikidata is done by citation.js.

Install pandoc, jq and citation-js:

$ sudo apt-get install pandoc jq
$ npm install --global citation-js

Define a function or script to extract citekeys from arbitrary documents (especially Markdown and TeX):

citekeys () { 
  pandoc -t json "$@" | jq -r '..|objects|select(.t=="Cite")|.c[0][].citationId'; 
}

Pipe Wikidata ids to citation-js:

citekeys *.md | awk '/^Q[1-9][0-9]*$/{print}' | citation-js

What's missing is a small script that stores all citation data in a JSON file (e.g. references.json) and only retrieve missing items. Support of human-readable citation key aliases (e.g. AuthorSunameYear) would also be nice. This script might become part of citation-js.