feat(ST2.EditorPackages): bump up all packages

- Refresh PackageCache with latest versions of everything
This commit is contained in:
Iristyle
2013-09-16 22:29:05 -04:00
parent 951be33c9e
commit 5ed4214a22
180 changed files with 9360 additions and 1211 deletions

View File

@@ -62,5 +62,13 @@
{
"caption": "StringEncode: Hexadecimal to Decimal",
"command": "hex_dec"
},
{
"caption": "StringEncode: Unicode to Hexadecimal",
"command": "unicode_hex"
},
{
"caption": "StringEncode: Hexadecimal to Unicode",
"command": "hex_unicode"
}
]

View File

@@ -0,0 +1,26 @@
Copyright (c) 2012, Colin T.A. Gray
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of this project.

View File

@@ -1,5 +1,5 @@
StringEncode plugin for Sublime Text 2
======================================
StringEncode
============
Converts characters from one "encoding" to another using a transformation (think HTML entities, not character encodings).
@@ -10,13 +10,22 @@ Installation
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/
1. Open the Sublime Text Packages folder
- OS X: ~/Library/Application Support/Sublime Text 3/Packages/
- Windows: %APPDATA%/Sublime Text 3/Packages/
- Linux: ~/.Sublime Text 3/Packages/
2. clone this repo
3. Install keymaps for the commands (see Example.sublime-keymap for my preferred keys)
### Sublime Text 2
1. Open the Sublime Text 2 Packages folder
2. clone this repo, but use the `st2` branch
git clone -b st2 git@github.com:colinta/SublimeStringEncode
Commands
--------

View File

@@ -1 +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)."}
{"url": "https://github.com/colinta/SublimeStringEncode", "version": "2013.08.20.19.57.08", "description": "Converts characters from one encoding to another using a transformation (think HTML entities, not character encodings)."}

View File

@@ -1,7 +1,17 @@
{
"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"
"author": "Colin T.A. Gray (colinta)",
"details": "https://github.com/colinta/SublimeStringEncode",
"labels": ["text manipulation"],
"releases": [
{
"details": "https://github.com/colinta/SublimeStringEncode/tree/master",
"sublime_text": "<3000"
},
{
"details": "https://github.com/colinta/SublimeStringEncode/tags",
"sublime_text": ">=3000"
}
]
}

View File

@@ -1,33 +1,25 @@
# coding: utf8
import sublime_plugin
import urllib
import base64
import re
import json
import sys
import sublime_plugin
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:
for region in self.view.sel():
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;",
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;", u"\xa0": "&nbsp;",
}
xml_escape_table = {
u"\"": "&quot;", u"'": "&#039;", u"<": "&lt;", u">": "&gt;"
@@ -100,7 +92,13 @@ class XmlEntitizeCommand(StringEncode):
for k in xml_escape_table:
v = xml_escape_table[k]
text = text.replace(k, v)
return text
ret = ''
for i, c in enumerate(text):
if ord(c) > 127:
ret += hex(ord(c)).replace('0x', '&#x') + ';'
else:
ret += c
return ret
class XmlDeentitizeCommand(StringEncode):
@@ -124,12 +122,12 @@ class JsonUnescapeCommand(StringEncode):
class UrlEncodeCommand(StringEncode):
def encode(self, text):
return urllib.quote(text)
return urllib.parse.quote(text)
class UrlDecodeCommand(StringEncode):
def encode(self, text):
return urllib.unquote(text)
return urllib.parse.unquote(text)
class Base64EncodeCommand(StringEncode):
@@ -163,3 +161,130 @@ class HexDecCommand(StringEncode):
class DecHexCommand(StringEncode):
def encode(self, text):
return hex(int(text))
class UnicodeHexCommand(StringEncode):
def encode(self, text):
hex_text = u''
text_bytes = bytes(text, 'utf-16')
if text_bytes[0:2] == b'\xff\xfe':
endian = 'little'
text_bytes = text_bytes[2:]
elif text_bytes[0:2] == b'\xfe\xff':
endian = 'big'
text_bytes = text_bytes[2:]
char_index = 0
for c in text_bytes:
if char_index == 0:
c1 = c
char_index += 1
elif char_index == 1:
c2 = c
if endian == 'little':
c1, c2 = c2, c1
tmp = (c1 << 8) + c2
if tmp < 0x80:
hex_text += chr(tmp)
char_index = 0
elif tmp >= 0xd800 and tmp <= 0xdbff:
char_index += 1
else:
hex_text += '\\u' + '{0:04x}'.format(tmp)
char_index = 0
elif char_index == 2:
c3 = c
char_index += 1
elif char_index == 3:
c4 = c
if endian == 'little':
c3, c4 = c4, c3
tmp1 = ((c1 << 8) + c2) - 0xd800
tmp2 = ((c3 << 8) + c4) - 0xdc00
tmp = (tmp1 * 0x400) + tmp2 + 0x10000
hex_text += '\\U' + '{0:08x}'.format(tmp)
char_index = 0
return hex_text
class HexUnicodeCommand(StringEncode):
def encode(self, text):
uni_text = text
endian = sys.byteorder
r = re.compile(r'\\u([0-9a-fA-F]{2})([0-9a-fA-F]{2})')
rr = r.search(uni_text)
while rr:
first_byte = int(rr.group(1), 16)
if first_byte >= 0xd8 and first_byte <= 0xdf:
# Surrogate pair
pass
else:
if endian == 'little':
b1 = int(rr.group(2), 16)
b2 = int(rr.group(1), 16)
else:
b1 = int(rr.group(1), 16)
b2 = int(rr.group(2), 16)
ch = bytes([b1, b2]).decode('utf-16')
uni_text = uni_text.replace(rr.group(0), ch)
rr = r.search(uni_text, rr.start(0)+1)
# Surrogate pair (2 bytes + 2 bytes)
r = re.compile(r'\\u([0-9a-fA-F]{2})([0-9a-fA-F]{2})\\u([0-9a-fA-F]{2})([0-9a-fA-F]{2})')
rr = r.search(uni_text)
while rr:
if endian == 'little':
b1 = int(rr.group(2), 16)
b2 = int(rr.group(1), 16)
b3 = int(rr.group(4), 16)
b4 = int(rr.group(3), 16)
else:
b1 = int(rr.group(1), 16)
b2 = int(rr.group(2), 16)
b3 = int(rr.group(3), 16)
b4 = int(rr.group(4), 16)
ch = bytes([b1, b2, b3, b4]).decode('utf-16')
uni_text = uni_text.replace(rr.group(0), ch)
rr = r.search(uni_text)
# Surrogate pair (4 bytes)
r = re.compile(r'\\U([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})')
rr = r.search(uni_text)
while rr:
tmp = (int(rr.group(1), 16) << 24) \
+ (int(rr.group(2), 16) << 16) \
+ (int(rr.group(3), 16) << 8) \
+ (int(rr.group(4), 16))
if (tmp <= 0xffff):
ch = chr(tmp)
else:
tmp -= 0x10000
c1 = 0xd800 + int(tmp / 0x400)
c2 = 0xdc00 + int(tmp % 0x400)
if endian == 'little':
b1 = c1 & 0xff
b2 = c1 >> 8
b3 = c2 & 0xff
b4 = c2 >> 8
else:
b1 = c1 >> 8
b2 = c1 & 0xff
b3 = c2 >> 8
b4 = c2 & 0xff
ch = bytes([b1, b2, b3, b4]).decode('utf-16')
uni_text = uni_text.replace(rr.group(0), ch)
rr = r.search(uni_text)
return uni_text