Skip to content

Instantly share code, notes, and snippets.

@dsanson
Created September 7, 2011 20:18
Show Gist options
  • Save dsanson/1201607 to your computer and use it in GitHub Desktop.
Save dsanson/1201607 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'bibtex'
match = ARGV.join(" ")
bibfile = "/Users/david/.pandoc/default.bib"
bib = BibTeX.open(bibfile)
bib.delete('@comment') #Avoid false hits in comments
entries = []
bib[/#{match}/i].each do |hit|
entries.push("{ 'word': '#{hit.key}', 'menu': '#{hit.author}, #{hit.title}' }")
end
puts "[" + entries.join(", ") + "]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment