-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathImage Tag.plist
52 lines (46 loc) · 1.51 KB
/
Image Tag.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>command</key>
<string>#!/usr/bin/env ruby18 -wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
require "shellwords"
require "cgi"
def tag_for_file(file, tab_stop = 0)
file_path = File.expand_path file
tag = "<img src=\"#{e_sn(CGI::escapeHTML file)}\""
dim = %x{ sips -g pixelWidth -g pixelHeight #{e_sh file_path} }
tag << " width=\"#$1\"" if dim =~ /pixelWidth: (\d+)/
tag << " height=\"#$1\"" if dim =~ /pixelHeight: (\d+)/
alt = File.basename(file, File.extname(file))
alt = alt.gsub(/[_-]+/, ' ').strip.gsub(/\b[a-z]/) { $&.upcase }
tag << " alt=\"\${#{tab_stop+1}:#{e_snp(CGI::escapeHTML alt)}}\""
tag << "#{ENV['TM_XHTML']}>"
end
if ENV.has_key? 'TM_DROPPED_FILES'
files = Shellwords.shellwords(ENV['TM_DROPPED_FILES'])
files.each_with_index do |file, tab_stop|
STDOUT << tag_for_file(file, tab_stop) << "\n"
end
else
STDOUT << tag_for_file(ENV['TM_DROPPED_FILE'])
end
</string>
<key>draggedFileExtensions</key>
<array>
<string>png</string>
<string>jpeg</string>
<string>jpg</string>
<string>gif</string>
</array>
<key>name</key>
<string>Insert Image With Dimensions</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>text.html</string>
<key>uuid</key>
<string>CD6D2CC6-6B33-11D9-BDFD-000D93589AF6</string>
</dict>
</plist>