Created
April 16, 2009 07:13
-
-
Save sofadesign/96285 to your computer and use it in GitHub Desktop.
Texmate command: open markdown links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Texmate command: open markdown links | |
# <http://macromates.com/> | |
# [My favorite editor](http://macromates.com/) | |
idx = ENV['TM_LINE_INDEX'].to_i | |
line = ENV['TM_CURRENT_LINE'] | |
alt_tokens = line.include?('<') && line.include?('>') | |
b_token = alt_tokens ? '<' : '(' | |
e_token = alt_tokens ? '>' : ')' | |
beginning = (idx - line[0,idx].reverse.index(b_token)) | |
ending = line[idx,line.length].index(e_token) + idx - 1 | |
link = line[beginning..ending] | |
`open #{link}` | |
# Input: Selected Text OR Scope | |
# Output: Discard | |
# Activation: Key Equivalent ^↘ | |
# Scope Selector: markup.underline.link.markdown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment