feat(SublimeText2.EditorPackages): cache packages

This commit is contained in:
Iristyle committed 2013-04-04 08:55:15 -04:00
1 parent d65666cdfc
commit c3efdad2c2
274 files changed
+26863

No files matched your search

@@ -0,0 +1,66 @@
[
{
"caption": "StringEncode: HTML Entitize",
"command": "html_entitize"
},
{
"caption": "StringEncode: HTML Deentitize",
"command": "html_deentitize"
},
{
"caption": "StringEncode: XML Entitize",
"command": "xml_entitize"
},
{
"caption": "StringEncode: XML Deentitize",
"command": "xml_deentitize"
},
{
"caption": "StringEncode: Safe HTML Entitize",
"command": "safe_html_entitize"
},
{
"caption": "StringEncode: Safe HTML Deentitize",
"command": "safe_html_deentitize"
},
{
"caption": "StringEncode: JSON Escape",
"command": "json_escape"
},
{
"caption": "StringEncode: JSON Unescape",
"command": "json_unescape"
},
{
"caption": "StringEncode: URL Encode",
"command": "url_encode"
},
{
"caption": "StringEncode: URL Decode",
"command": "url_decode"
},
{
"caption": "StringEncode: Base64 Encode",
"command": "base64_encode"
},
{
"caption": "StringEncode: Base64 Decode",
"command": "base64_decode"
},
{
"caption": "StringEncode: Escape regex",
"command": "escape_regex"
},
{
"caption": "StringEncode: Escape LIKE",
"command": "escape_like"
},
{
"caption": "StringEncode: Decimal to Hexadecimal",
"command": "dec_hex"
},
{
"caption": "StringEncode: Hexadecimal to Decimal",
"command": "hex_dec"
}
]
@@ -0,0 +1,14 @@
[
{ "keys": ["super+shift+7"], "command": "xml_entitize", "scope": "text.xml" },
{ "keys": ["super+ctrl+7"], "command": "xml_deentitize", "scope": "text.xml" },
{ "keys": ["super+shift+7"], "command": "html_entitize" },
{ "keys": ["super+ctrl+7"], "command": "html_deentitize" },
{ "keys": ["super+shift+8"], "command": "json_escape" },
{ "keys": ["super+ctrl+8"], "command": "json_unescape" },
{ "keys": ["super+shift+6"], "command": "base64_encode" },
{ "keys": ["super+ctrl+6"], "command": "base64_decode" },
{ "keys": ["super+shift+5"], "command": "url_encode" },
{ "keys": ["super+ctrl+5"], "command": "url_decode" },
{ "keys": ["ctrl+shift+r"], "command": "escape_regex" },
{ "keys": ["super+ctrl+3"], "command": "hex_dec" }
]
@@ -0,0 +1,52 @@
StringEncode plugin for Sublime Text 2
======================================
Converts characters from one "encoding" to another using a transformation (think HTML entities, not character encodings).
Installation
------------
1. Using Package Control, install "StringEncode"
Or:
1. Open the Sublime Text 2 Packages folder
- OS X: ~/Library/Application Support/Sublime Text 2/Packages/
- Windows: %APPDATA%/Sublime Text 2/Packages/
- Linux: ~/.Sublime Text 2/Packages/
2. clone this repo
3. Install keymaps for the commands (see Example.sublime-keymap for my preferred keys)
Commands
--------
`html_entitize`: Converts characters to their HTML entity
`html_deentitize`: Converts HTML entities to a character
`url_encode`: Uses urllib.quote to escape special URL characters
`url_decode`: Uses urllib.unquote to convert escaped URL characters
`json_escape`: Escapes a string and surrounds it in quotes, according to the JSON encoding.
`json_unescape`: Unescapes a string (include the quotes!) according to JSON encoding.
`base64_encode`: Uses base64 to encode into base64
`base64_decode`: Uses base64 to decode from base64
`escape_regex`: Escapes regex meta characters
`escape_like`: Escapes SQL-LIKE meta characters
`safe_html_entitize`: Converts characters to their HTML entity, but preserves HTML reserved characters
`safe_html_deentitize`: Converts HTML entities to a character, but preserves HTML reserved characters
TODO
----
`xml_entitize`: Converts characters to their XML entity
`xml_deentitize`: Converts XML entities to a character
@@ -0,0 +1 @@
{"url": "https://github.com/colinta/SublimeStringEncode", "version": "1.5.1", "description": "Converts characters from one encoding to another using a transformation (think HTML entities, not character encodings)."}
@@ -0,0 +1,7 @@
{
"repo": "SublimeStringEncode",
"name": "StringEncode",
"description": "Converts characters from one encoding to another using a transformation (think HTML entities, not character encodings).",
"author": "Colin Thomas-Arnold (colinta)",
"homepage": "https://github.com/colinta/SublimeStringEncode"
}
@@ -0,0 +1,165 @@
# coding: utf8
import sublime_plugin
import urllib
import base64
import re
import json
class StringEncode(sublime_plugin.TextCommand):
def run(self, edit):
e = self.view.begin_edit('encode')
regions = [region for region in self.view.sel()]
# sort by region.end() DESC
def get_end(region):
return region.end()
regions.sort(key=get_end, reverse=True)
for region in regions:
if region.empty():
continue
text = self.view.substr(region)
replacement = self.encode(text)
self.view.replace(edit, region, replacement)
self.view.end_edit(e)
html_escape_table = {
u"\"": "&quot;", u"'": "&#039;", u"<": "&lt;", u">": "&gt;", u"¡": "&iexcl;", u"¢": "&cent;", u"£": "&pound;", u"¤": "&curren;", u"¥": "&yen;", u"¦": "&brvbar;", u"§": "&sect;", u"¨": "&uml;", u"©": "&copy;", u"ª": "&ordf;", u"«": "&laquo;", u"¬": "&not;", u"®": "&reg;", u"¯": "&macr;", u"°": "&deg;", u"±": "&plusmn;", u"²": "&sup2;", u"³": "&sup3;", u"´": "&acute;", u"µ": "&micro;", u"": "&para;", u"·": "&middot;", u"¸": "&cedil;", u"¹": "&sup1;", u"º": "&ordm;", u"»": "&raquo;", u"¼": "&frac14;", u"½": "&frac12;", u"¾": "&frac34;", u"¿": "&iquest;", u"À": "&Agrave;", u"Á": "&Aacute;", u"Â": "&Acirc;", u"Ã": "&Atilde;", u"Ä": "&Auml;", u"Å": "&Aring;", u"Æ": "&AElig;", u"Ç": "&Ccedil;", u"È": "&Egrave;", u"É": "&Eacute;", u"Ê": "&Ecirc;", u"Ë": "&Euml;", u"Ì": "&Igrave;", u"Í": "&Iacute;", u"Î": "&Icirc;", u"Ï": "&Iuml;", u"Ð": "&ETH;", u"Ñ": "&Ntilde;", u"Ò": "&Ograve;", u"Ó": "&Oacute;", u"Ô": "&Ocirc;", u"Õ": "&Otilde;", u"Ö": "&Ouml;", u"×": "&times;", u"Ø": "&Oslash;", u"Ù": "&Ugrave;", u"Ú": "&Uacute;", u"Û": "&Ucirc;", u"Ü": "&Uuml;", u"Ý": "&Yacute;", u"Þ": "&THORN;", u"ß": "&szlig;", u"à": "&agrave;", u"á": "&aacute;", u"â": "&acirc;", u"ã": "&atilde;", u"ä": "&auml;", u"å": "&aring;", u"æ": "&aelig;", u"ç": "&ccedil;", u"è": "&egrave;", u"é": "&eacute;", u"ê": "&ecirc;", u"ë": "&euml;", u"ì": "&igrave;", u"í": "&iacute;", u"î": "&icirc;", u"ï": "&iuml;", u"ð": "&eth;", u"ñ": "&ntilde;", u"ò": "&ograve;", u"ó": "&oacute;", u"ô": "&ocirc;", u"õ": "&otilde;", u"ö": "&ouml;", u"÷": "&divide;", u"ø": "&oslash;", u"ù": "&ugrave;", u"ú": "&uacute;", u"û": "&ucirc;", u"ü": "&uuml;", u"ý": "&yacute;", u"þ": "&thorn;", u"ÿ": "&yuml;", u"Œ": "&OElig;", u"œ": "&oelig;", u"Š": "&Scaron;", u"š": "&scaron;", u"Ÿ": "&Yuml;", u"ƒ": "&fnof;", u"ˆ": "&circ;", u"˜": "&tilde;", u"Α": "&Alpha;", u"Β": "&Beta;", u"Γ": "&Gamma;", u"Δ": "&Delta;", u"Ε": "&Epsilon;", u"Ζ": "&Zeta;", u"Η": "&Eta;", u"Θ": "&Theta;", u"Ι": "&Iota;", u"Κ": "&Kappa;", u"Λ": "&Lambda;", u"Μ": "&Mu;", u"Ν": "&Nu;", u"Ξ": "&Xi;", u"Ο": "&Omicron;", u"Π": "&Pi;", u"Ρ": "&Rho;", u"Σ": "&Sigma;", u"Τ": "&Tau;", u"Υ": "&Upsilon;", u"Φ": "&Phi;", u"Χ": "&Chi;", u"Ψ": "&Psi;", u"Ω": "&Omega;", u"α": "&alpha;", u"β": "&beta;", u"γ": "&gamma;", u"δ": "&delta;", u"ε": "&epsilon;", u"ζ": "&zeta;", u"η": "&eta;", u"θ": "&theta;", u"ι": "&iota;", u"κ": "&kappa;", u"λ": "&lambda;", u"μ": "&mu;", u"ν": "&nu;", u"ξ": "&xi;", u"ο": "&omicron;", u"π": "&pi;", u"ρ": "&rho;", u"ς": "&sigmaf;", u"σ": "&sigma;", u"τ": "&tau;", u"υ": "&upsilon;", u"φ": "&phi;", u"χ": "&chi;", u"ψ": "&psi;", u"ω": "&omega;", u"ϑ": "&thetasym;", u"ϒ": "&upsih;", u"ϖ": "&piv;", u"–": "&ndash;", u"—": "&mdash;", u"‘": "&lsquo;", u"’": "&rsquo;", u"‚": "&sbquo;", u"“": "&ldquo;", u"”": "&rdquo;", u"„": "&bdquo;", u"†": "&dagger;", u"‡": "&Dagger;", u"•": "&bull;", u"…": "&hellip;", u"‰": "&permil;", u"′": "&prime;", u"″": "&Prime;", u"‹": "&lsaquo;", u"›": "&rsaquo;", u"‾": "&oline;", u"⁄": "&frasl;", u"€": "&euro;", u"ℑ": "&image;", u"℘": "&weierp;", u"ℜ": "&real;", u"™": "&trade;", u"ℵ": "&alefsym;", u"←": "&larr;", u"↑": "&uarr;", u"→": "&rarr;", u"↓": "&darr;", u"↔": "&harr;", u"↵": "&crarr;", u"⇐": "&lArr;", u"⇑": "&uArr;", u"⇒": "&rArr;", u"⇓": "&dArr;", u"⇔": "&hArr;", u"∀": "&forall;", u"∂": "&part;", u"∃": "&exist;", u"∅": "&empty;", u"∇": "&nabla;", u"∈": "&isin;", u"∉": "&notin;", u"∋": "&ni;", u"∏": "&prod;", u"∑": "&sum;", u"−": "&minus;", u"∗": "&lowast;", u"√": "&radic;", u"∝": "&prop;", u"∞": "&infin;", u"∠": "&ang;", u"∧": "&and;", u"∨": "&or;", u"∩": "&cap;", u"∪": "&cup;", u"∫": "&int;", u"∴": "&there4;", u"∼": "&sim;", u"≅": "&cong;", u"≈": "&asymp;", u"≠": "&ne;", u"≡": "&equiv;", u"≤": "&le;", u"≥": "&ge;", u"⊂": "&sub;", u"⊃": "&sup;", u"⊄": "&nsub;", u"⊆": "&sube;", u"⊇": "&supe;", u"⊕": "&oplus;", u"⊗": "&otimes;", u"⊥": "&perp;", u"⋅": "&sdot;", u"⌈": "&lceil;", u"⌉": "&rceil;", u"⌊": "&lfloor;", u"⌋": "&rfloor;", u"〈": "&lang;", u"〉": "&rang;", u"◊": "&loz;", u"♠": "&spades;", u"♣": "&clubs;", u"♥": "&hearts;", u"♦": "&diams;",
}
xml_escape_table = {
u"\"": "&quot;", u"'": "&#039;", u"<": "&lt;", u">": "&gt;"
}
html_reserved_list = (u"\"", u"'", u"<", u">", u"&")
class HtmlEntitizeCommand(StringEncode):
def encode(self, text):
text = text.replace('&', '&amp;')
for k in html_escape_table:
v = html_escape_table[k]
text = text.replace(k, v)
ret = ''
for i, c in enumerate(text):
if ord(c) > 127:
ret += hex(ord(c)).replace('0x', '&#x') + ';'
else:
ret += c
return ret
class HtmlDeentitizeCommand(StringEncode):
def encode(self, text):
for k in html_escape_table:
v = html_escape_table[k]
text = text.replace(v, k)
while re.search('&#[xX][a-fA-F0-9]+;', text):
match = re.search('&#[xX]([a-fA-F0-9]+);', text)
text = text.replace(match.group(0), unichr(int('0x' + match.group(1), 16)))
text = text.replace('&amp;', '&')
return text
class SafeHtmlEntitizeCommand(StringEncode):
def encode(self, text):
for k in html_escape_table:
# skip HTML reserved characters
if k in html_reserved_list:
continue
v = html_escape_table[k]
text = text.replace(k, v)
ret = ''
for i, c in enumerate(text):
if ord(c) > 127:
ret += hex(ord(c)).replace('0x', '&#x') + ';'
else:
ret += c
return ret
class SafeHtmlDeentitizeCommand(StringEncode):
def encode(self, text):
for k in html_escape_table:
# skip HTML reserved characters
if k in html_reserved_list:
continue
v = html_escape_table[k]
text = text.replace(v, k)
while re.search('&#[xX][a-fA-F0-9]+;', text):
match = re.search('&#[xX]([a-fA-F0-9]+);', text)
text = text.replace(match.group(0), unichr(int('0x' + match.group(1), 16)))
text = text.replace('&amp;', '&')
return text
class XmlEntitizeCommand(StringEncode):
def encode(self, text):
text = text.replace('&', '&amp;')
for k in xml_escape_table:
v = xml_escape_table[k]
text = text.replace(k, v)
return text
class XmlDeentitizeCommand(StringEncode):
def encode(self, text):
for k in xml_escape_table:
v = xml_escape_table[k]
text = text.replace(v, k)
text = text.replace('&amp;', '&')
return text
class JsonEscapeCommand(StringEncode):
def encode(self, text):
return json.dumps(text)
class JsonUnescapeCommand(StringEncode):
def encode(self, text):
return json.loads(text)
class UrlEncodeCommand(StringEncode):
def encode(self, text):
return urllib.quote(text)
class UrlDecodeCommand(StringEncode):
def encode(self, text):
return urllib.unquote(text)
class Base64EncodeCommand(StringEncode):
def encode(self, text):
return base64.b64encode(text)
class Base64DecodeCommand(StringEncode):
def encode(self, text):
return base64.b64decode(text)
class Escaper(StringEncode):
def encode(self, text):
return re.sub(r'(?<!\\)(%s)' % self.meta, r'\\\1', text)
class EscapeRegexCommand(Escaper):
meta = r'[\\*.+^$()\[\]\{\}]'
class EscapeLikeCommand(Escaper):
meta = r'[%_]'
class HexDecCommand(StringEncode):
def encode(self, text):
return str(int(text, 16))
class DecHexCommand(StringEncode):
def encode(self, text):
return hex(int(text))