Skip to content

Instantly share code, notes, and snippets.

@dsanson
Created November 21, 2011 16:25
Show Gist options
  • Save dsanson/1383132 to your computer and use it in GitHub Desktop.
Save dsanson/1383132 to your computer and use it in GitHub Desktop.
Generate a bibtex file containing works cited in a given pandoc extended markdown file
#!/usr/bin/env ruby
bibfile = "~/.pandoc/default.bib"
matches = ARGF.read.scan(/@(.*?)[\.,:;\] ]/)
reg = "\\(" + matches.join("\\)\\|\\(") + "\\)"
system 'bibtool -X \'' + reg + '\' ' + bibfile
@dsanson
Copy link
Author

dsanson commented Nov 21, 2011

Generates a bibtex file containing only works cited in a given pandoc extended markdown file. Usage

$ cat example.markdown | extract_bib.rb > example.bib
$ extract_bib.rb example.markdown > example.bib

Depends on bibtool. Change the value of bibfile to point to your master bibtex database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment