diff --git a/Preferences/Autocomplete citations.tmPreferences b/Preferences/Autocomplete citations.tmPreferences index 29f0fc0..26c4e58 100644 --- a/Preferences/Autocomplete citations.tmPreferences +++ b/Preferences/Autocomplete citations.tmPreferences @@ -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 diff --git a/README.markdown b/README.markdown index b4584d6..7c33c5d 100644 --- a/README.markdown +++ b/README.markdown @@ -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][]. @@ -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