Skip to content

Instantly share code, notes, and snippets.

@retrography
Created September 25, 2017 01:55
Show Gist options
  • Save retrography/1499a6b6617942c3c3a4c8600af5a058 to your computer and use it in GitHub Desktop.
Save retrography/1499a6b6617942c3c3a4c8600af5a058 to your computer and use it in GitHub Desktop.
Parses the reference from the clipboard using AnyStyle parser and returns the corresponding bibtex record back into the clipboard
Encoding.default_external='utf-8'
Encoding.default_internal='utf-8'
require 'anystyle/parser'
require 'clipboard'
text = Clipboard.paste.tr("\n\r", " ").gsub(/\s+/,' ').gsub(/([a-zA-Z])- ([a-zA-Z])/, '\1\2')
ref = Anystyle.parse(text, :bibtex).to_s
Clipboard.copy(ref)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment