mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
56 lines
1.7 KiB
Plaintext
56 lines
1.7 KiB
Plaintext
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>beforeRunningCommand</key>
|
|
<string>nop</string>
|
|
<key>command</key>
|
|
<string>#!/usr/bin/env ruby
|
|
|
|
class String
|
|
def escape(char)
|
|
gsub(/\\.|#{Regexp.quote(char)}/) { |match| match == char ? "\\#{char}" : match }
|
|
end
|
|
|
|
def unescape(char)
|
|
gsub(/\\./) { |match| match == "\\#{char}" ? char : match }
|
|
end
|
|
end
|
|
|
|
print case str = STDIN.read
|
|
# Handle standard quotes
|
|
when /\A"(.*)"\z/m; "'" + $1.unescape('"').escape("'") + "'"
|
|
when /\A'(.*)'\z/m; "%Q{" + $1.unescape("'").escape("}") + "}"
|
|
when /\A%[Qq]?\{(.*)\}\z/m; '"' + $1.unescape("}").escape('"') + '"'
|
|
|
|
# Handle the more esoteric quote styles
|
|
when /\A%[Qq]?\[(.*)(\])\z/m,
|
|
/\A%[Qq]?\((.*)(\))\z/m,
|
|
/\A%[Qq]?<(.*)(>)\z/m; '"' + $1.unescape($2).escape('"') + '"'
|
|
when /\A%[Qq]?(.)(.*)\1\z/m; '"' + $2.unescape($1).escape('"') + '"'
|
|
|
|
# Handle shell escapes
|
|
when /\A`(.*)`\z/m; "%x{" + $1.unescape("`").escape("}") + "}"
|
|
when /\A%x\{(.*)\}\z/m; "`" + $1.unescape("}").escape("`") + "`"
|
|
|
|
# Default case
|
|
else str
|
|
end
|
|
</string>
|
|
<key>fallbackInput</key>
|
|
<string>scope</string>
|
|
<key>input</key>
|
|
<string>selection</string>
|
|
<key>keyEquivalent</key>
|
|
<string>^"</string>
|
|
<key>name</key>
|
|
<string>Toggle Quote Style</string>
|
|
<key>output</key>
|
|
<string>replaceSelectedText</string>
|
|
<key>scope</key>
|
|
<string>source.ruby string.quoted.double, source.ruby string.quoted.single, source.ruby string</string>
|
|
<key>uuid</key>
|
|
<string>6519CB08-8326-4B77-A251-54722FFBFC1F</string>
|
|
</dict>
|
|
</plist>
|