Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Commit

Permalink
Adding support for RIS and JSON bibfiles; fixing support for MODS
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanson committed Sep 3, 2011
1 parent f9cf429 commit dfb7732
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Preferences/Autocomplete citations.tmPreferences
Expand Up @@ -14,8 +14,15 @@ bib = ENV["TM_PANDOC_BIB"]
phrase = ENV["TM_CURRENT_WORD"]
File.open(bib) { |file|
text = file.read
keys = text.scan(/@.*?\{(#{phrase}.*?),/i)
keys = keys + text.scan(/<mods ID=\"(.*?)\">/i)
keys = []
# match bibtex keys
keys = keys + text.scan(/@.*?\{[\s]*(#{phrase}.*?),/i)
# match mods keys
keys = keys + text.scan(/<mods ID=\"(#{phrase}.*?)\">/i)
# match RIS keys
keys = keys + text.scan(/^ID\s+-\s+(#{phrase}.*)$/i)
# match JSON CSL keys
keys = keys + text.scan(/\"id\":\s+\"(#{phrase}.*?)\"/i)
keys.uniq!
keys.sort!
puts keys
Expand Down
19 changes: 14 additions & 5 deletions README.markdown
Expand Up @@ -3,6 +3,12 @@
I've mostly abandoned TextMate for MacVim. If you are thinking about
doing this too, check out [vim-pandoc][], my pandoc bundle for vim.

One consequence is that this bundle is getting less love from me. If
you want to give it some love, feel free to fork it, and I'll be happy
to pull back in any improvements you make. If you want a more serious
relationship---not just casual forking---we could move this toa shared
repo, or I could transfer ownership to you.

# Pandoc TextMate Bundle README

This is a TextMate bundle for use with John MacFarlane's [pandoc][].
Expand Down Expand Up @@ -56,11 +62,14 @@ Shell Variables:

### Autocompletion of Citation Keys

If $TM\_PANDOC\_BIB points to a bibtex or mods xml file, then you can
use TextMate's autocompletion (type part of a word then hit the ESCAPE
key) to complete citation keys. I have no idea how robust this is: I am
just using regexps in ruby to find the citation keys. It shouldn't be
hard to expand support for other bibliography formats.
If $TM\_PANDOC\_BIB points to a bibtex, ris, citeproc json, or mods xml
file, then you can use TextMate's autocompletion (type part of a word
then hit the ESCAPE key) to complete citation keys. I have no idea how
robust this is: I am just using regexps in ruby to find the citation
keys. It shouldn't be hard to expand support for other bibliography
formats: let me know if there is a format that you are using that is
not supported. (FYI: support for completion from a zotero database is
something I'd like to add once zotero's api allows it.)

### Markdown Tidy

Expand Down

0 comments on commit dfb7732

Please sign in to comment.