Beefed converter script a bit. Still an ugly hack. Imported HTML and CSS snippets from Textmate

This commit is contained in:
Holger Rapp 2009-07-19 22:53:25 +02:00
parent c3dff61ef1
commit 11c20ee093
3 changed files with 664 additions and 8 deletions

411
UltiSnips/tm_css.snippets Normal file
View File

@ -0,0 +1,411 @@
snippet ! "!important CSS (!)"
${1:!important}
endsnippet
snippet fixed "Fixed Position Bottom 100% wide IE6"
${2:bottom: auto;}top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-${1:THE HEIGHT OF THIS THING IN PIXELS}));
${3:left: expression(eval(document.documentElement.scrollLeft));
}${4:width: expression(eval(document.documentElement.clientWidth));}$0
endsnippet
snippet background "background-attachment: scroll:fixed (background)"
background-attachment: ${1:scroll/fixed};$0
endsnippet
snippet background "background-color: color-hex (background)"
background-color: #${1:DDD};$0
endsnippet
snippet background "background-color: color-name (background)"
background-color: ${1:red};$0
endsnippet
snippet background "background-color: color-rgb (background)"
background-color: rgb(${1:255},${2:255},${3:255});$0
endsnippet
snippet background "background-color: transparent (background)"
background-color: transparent;$0
endsnippet
snippet background "background-image: none (background)"
background-image: none;$0
endsnippet
snippet background "background-image: url (background)"
background-image: url($1);$0
endsnippet
snippet background "background-position: position (background)"
background-position: ${1:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0
endsnippet
snippet background "background-repeat: r:r-x:r-y:n-r (background)"
background-repeat: ${1:repeat/repeat-x/repeat-y/no-repeat};$0
endsnippet
snippet background "background: color image repeat attachment position (background)"
background:${6: #${1:DDD}} url($2) ${3:repeat/repeat-x/repeat-y/no-repeat} ${4:scroll/fixed} ${5:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0
endsnippet
snippet border "border-bottom-color: size style color (border)"
border-bottom-color: #${1:999};$0
endsnippet
snippet border "border-bottom-style: size style color (border)"
border-bottom-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-bottom-width: size style color (border)"
border-bottom-width: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-bottom: size style color (border)"
border-bottom: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-color: color (border)"
border-color: ${1:999};$0
endsnippet
snippet border "border-left-color: color (border)"
border-right-color: #${1:999};$0
endsnippet
snippet border "border-left-style: style (border)"
border-left-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-left-width: size (border)"
border-left-width: ${1:1}px
endsnippet
snippet border "border-left: size style color (border)"
border-left: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-right-color: color (border)"
border-right-color: #${1:999};$0
endsnippet
snippet border "border-right-style: style (border)"
border-right-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-right-width: size (border)"
border-right-width: ${1:1}px
endsnippet
snippet border "border-right: size style color (border)"
border-right: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-style: style (border)"
border-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-top-color: color (border)"
border-top-color: #${1:999};$0
endsnippet
snippet border "border-top-style: style (border)"
border-top-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0
endsnippet
snippet border "border-top-width: size (border)"
border-top-width: ${1:1}px
endsnippet
snippet border "border-top: size style color (border)"
border-top: ${1:1}px ${2:solid} #${3:999};$0
endsnippet
snippet border "border-width: width (border)"
border-width: ${1:1px};$0
endsnippet
snippet border "border: size style color (border)"
border: ${1:1px} ${2:solid} #${3:999};$0
endsnippet
snippet clear "clear: value (clear)"
clear: ${1:left/right/both/none};$0
endsnippet
snippet color "color: color-hex (color)"
color: #${1:DDD};$0
endsnippet
snippet color "color: color-name (color)"
color: ${1:red};$0
endsnippet
snippet color "color: color-rgb (color)"
color: rgb(${1:255},${2:255},${3:255});$0
endsnippet
snippet cursor "cursor: type (cursor)"
cursor: ${1:default/auto/crosshair/pointer/move/*-resize/text/wait/help};$0
endsnippet
snippet cursor "cursor: url (cursor)"
cursor: url($1);$0
endsnippet
snippet direction "direction: ltr|rtl (direction)"
direction: ${1:ltr|rtl};$0
endsnippet
snippet display "display: block (display)"
display: block;$0
endsnippet
snippet display "display: common-types (display)"
display: ${1:none/inline/block/list-item/run-in/compact/marker};$0
endsnippet
snippet display "display: inline (display)"
display: inline;$0
endsnippet
snippet display "display: table-types (display)"
display: ${1:table/inline-table/table-row-group/table-header-group/table-footer-group/table-row/table-column-group/table-column/table-cell/table-caption};$0
endsnippet
snippet background "filter: AlphaImageLoader [for IE PNGs] (background)"
${3:background-image: none;
}filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1:${TM_SELECTED_TEXT:/images/transparent.png}}', sizingMethod='${2:image/scale/crop}');
endsnippet
snippet float "float: left:right:none (float)"
float: ${1:left/right/none};$0
endsnippet
snippet font "font-family: family (font)"
font-family: ${1:Arial, "MS Trebuchet"}, ${2:sans-}serif;$0
endsnippet
snippet font "font-size: size (font)"
font-size: ${1:100%};$0
endsnippet
snippet font "font-style: normal:italic:oblique (font)"
font-style: ${1:normal/italic/oblique};$0
endsnippet
snippet font "font-variant: normal:small-caps (font)"
font-variant: ${1:normal/small-caps};$0
endsnippet
snippet font "font-weight: weight (font)"
font-weight: ${1:normal/bold};$0
endsnippet
snippet font "font: style variant weight size:line-height font -family (font)"
font: ${1:normal/italic/oblique} ${2:normal/small-caps} ${3:normal/bold} ${4:1em/1.5em} ${5:Arial}, ${6:sans-}serif;$0
endsnippet
snippet font "font: size font (font)"
font: ${1:75%} ${2:"Lucida Grande", "Trebuchet MS", Verdana,} ${3:sans-}serif;$0
endsnippet
snippet letter "letter-spacing: length-em (letter)"
letter-spacing: $1em;$0
endsnippet
snippet letter "letter-spacing: length-px (letter)"
letter-spacing: $1px;$0
endsnippet
snippet list "list-style-image: url (list)"
list-style-image: url($1);$0
endsnippet
snippet list "list-style-position: pos (list)"
list-style-position: ${1:inside/outside};$0
endsnippet
snippet list "list-style-type: asian (list)"
list-style-type: ${1:cjk-ideographic/hiragana/katakana/hiragana-iroha/katakana-iroha};$0
endsnippet
snippet list "list-style-type: marker(list)"
list-style-type: ${1:none/disc/circle/square};$0
endsnippet
snippet list "list-style-type: numeric (list)"
list-style-type: ${1:decimal/decimal-leading-zero/zero};$0
endsnippet
snippet list "list-style-type: other (list)"
list-style-type: ${1:hebrew/armenian/georgian};$0
endsnippet
snippet list "list-style-type: roman-alpha-greek (list)"
list-style-type: ${1:lower-roman/upper-roman/lower-alpha/upper-alpha/lower-greek/lower-latin/upper-latin};$0
endsnippet
snippet list "list-style: type position image (list)"
list-style: ${1:none/disc/circle/square/decimal/zero} ${2:inside/outside} url($3);$0
endsnippet
snippet margin "margin-bottom: length (margin)"
margin-bottom: ${1:20px};$0
endsnippet
snippet margin "margin-left: length (margin)"
margin-left: ${1:20px};$0
endsnippet
snippet margin "margin-right: length (margin)"
margin-right: ${1:20px};$0
endsnippet
snippet margin "margin-top: length (margin)"
margin-top: ${1:20px};$0
endsnippet
snippet margin "margin: all (margin)"
margin: ${1:20px};$0
endsnippet
snippet margin "margin: T R B L (margin)"
margin: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0
endsnippet
snippet margin "margin: V H (margin)"
margin: ${1:20px} ${2:0px};$0
endsnippet
snippet marker "marker-offset: auto (marker)"
marker-offset: auto;$0
endsnippet
snippet marker "marker-offset: length (marker)"
marker-offset: ${1:10px};$0
endsnippet
snippet opacity "opacity: [for Safari, FF and IE] (opacity)"
opacity: ${1:0.5};${100:
}-moz-opacity: ${1:0.5};${100:
}filter:alpha(opacity=${2:${1/(1?)0?\.(.*)/$1$2/}${1/^\d*\.\d\d+$|^\d*$|(^\d\.\d$)/(?1:0)/}});$0
endsnippet
snippet overflow "overflow: type (overflow)"
overflow: ${1:visible/hidden/scroll/auto};$0
endsnippet
snippet padding "padding-bottom: length (margin)"
padding-bottom: ${1:20px};$0
endsnippet
snippet padding "padding-left: length (margin)"
padding-left: ${1:20px};$0
endsnippet
snippet padding "padding-right: length (margin)"
padding-right: ${1:20px};$0
endsnippet
snippet padding "padding-top: length (margin)"
padding-top: ${1:20px};$0
endsnippet
snippet padding "padding: T R B L (padding)"
padding: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0
endsnippet
snippet padding "padding: V H (padding)"
padding: ${1:20px} ${2:0px};$0
endsnippet
snippet padding "padding: all (padding)"
padding: ${1:20px};$0
endsnippet
snippet position "position: type (position)"
position: ${1:static/relative/absolute/fixed};$0
endsnippet
snippet { "properties { } ( } )"
{
/* $1 */
$0
endsnippet
snippet scrollbar "scrollbar"
scrollbar-base-color: ${1:#CCCCCC};${2:
scrollbar-arrow-color: ${3:#000000};
scrollbar-track-color: ${4:#999999};
scrollbar-3dlight-color: ${5:#EEEEEE};
scrollbar-highlight-color: ${6:#FFFFFF};
scrollbar-face-color: ${7:#CCCCCC};
scrollbar-shadow-color: ${9:#999999};
scrollbar-darkshadow-color: ${8:#666666};}
endsnippet
snippet selection "selection"
$1::-moz-selection,
$1::selection {
color: ${2:inherit};
background: ${3:inherit};
}
endsnippet
snippet text "text-align: left:center:right (txt)"
text-align: ${1:left/right/center/justify};$0
endsnippet
snippet text "text-decoration: none:underline:overline:line-through:blink (text)"
text-decoration: ${1:none/underline/overline/line-through/blink};$0
endsnippet
snippet text "text-indent: length (text)"
text-indent: ${1:10}px;$0
endsnippet
snippet text "text-shadow: color-hex x y blur (text)"
text-shadow: #${1:DDD} ${2:10px} ${3:10px} ${4:2px};$0
endsnippet
snippet text "text-shadow: color-rgb x y blur (text)"
text-shadow: rgb(${1:255},${2:255},${3:255}) ${4:10px} ${5:10px} ${6:2px};$0
endsnippet
snippet text "text-shadow: none (text)"
text-shadow: none;$0
endsnippet
snippet text "text-transform: capitalize:upper:lower (text)"
text-transform: ${1:capitalize/uppercase/lowercase};$0
endsnippet
snippet text "text-transform: none (text)"
text-transform: none;$0
endsnippet
snippet vertical "vertical-align: type (vertical)"
vertical-align: ${1:baseline/sub/super/top/text-top/middle/bottom/text-bottom/length/%};$0
endsnippet
snippet visibility "visibility: type (visibility)"
visibility: ${1:visible/hidden/collapse};$0
endsnippet
snippet white "white-space: normal:pre:nowrap (white)"
white-space: ${1:normal/pre/nowrap};$0
endsnippet
snippet word "word-spacing: length (word)"
word-spacing: ${1:10px};$0
endsnippet
snippet word "word-spacing: normal (word)"
word-spacing: normal;$0
endsnippet
snippet z "z-index: index (z)"
z-index: $1;$0
endsnippet

224
UltiSnips/tm_html.snippets Normal file
View File

@ -0,0 +1,224 @@
###########################################################################
# TextMate Snippets #
###########################################################################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
snippet doctype "DocType XHTML 1.0 Strict"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
endsnippet
snippet doctype "DocType XHTML 1.0 Transitional"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
endsnippet
snippet doctype "DocType XHTML 1.1"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
endsnippet
snippet down "Down (down)"
&#x2193;
endsnippet
snippet movie "Embed QT movie (movie)"
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="$1"${TM_XHTML}>
<param name="controller" value="$4"${TM_XHTML}>
<param name="autoplay" value="$5"${TM_XHTML}>
<embed src="${1:movie.mov}"
width="${2:320}" height="${3:240}"
controller="${4:true}" autoplay="${5:true}"
scale="tofit" cache="true"
pluginspage="http://www.apple.com/quicktime/download/"
${TM_XHTML}>
</object>
endsnippet
snippet enter "Enter (enter)"
&#x2305;
endsnippet
snippet escape "Escape (escape)"
&#x238B;
endsnippet
snippet fieldset "Fieldset"
<fieldset id="${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}" ${2:class="${3:}"}>
<legend></legend>
$0
</fieldset>
endsnippet
snippet doctype "HTML - 4.0 Transitional (doctype)"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 5_0 only"
<!--[if IE 5.0]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 5.0 only }}<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 5_5 only"
<!--[if IE 5.5000]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 5.5 only }}<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 5_x"
<!--[if lt IE 6]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 5.x }}<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 6 and below"
<!--[if lte IE 6]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 6 and below }}<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 6 only"
<!--[if IE 6]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 6 only }}<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 7+"
<!--[if gte IE 7]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer 7 and above }}<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer"
<!--[if IE]>${1:${TM_SELECTED_TEXT: IE Conditional Comment: Internet Explorer }}<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: NOT Internet Explorer"
<!--[if !IE]><!-->${1:${TM_SELECTED_TEXT: IE Conditional Comment: NOT Internet Explorer }}<!-- <![endif]-->$0
endsnippet
snippet input "Input with Label"
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}${TM_XHTML}>
endsnippet
snippet left "Left (left)"
&#x2190;
endsnippet
snippet option "Option (option)"
&#x2325;
endsnippet
snippet opt "Option"
<option${1: value="${2:option}"}>${3:$2}</option>
endsnippet
snippet return "Return (return)"
&#x21A9;
endsnippet
snippet right "Right (right)"
&#x2192;
endsnippet
snippet select "Select Box"
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}>
<option${9: value="${10:option1}"}>${11:$10}</option>
<option${12: value="${13:option2}"}>${14:$13}</option>${15:}
$0
</select>
endsnippet
snippet shift "Shift (shift)"
&#x21E7;
endsnippet
snippet tab "Tab (tab)"
&#x21E5;
endsnippet
snippet up "Up (up)"
&#x2191;
endsnippet
snippet input "XHTML <input>"
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}${TM_XHTML}>
endsnippet
snippet textarea "XHTML <textarea>"
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
endsnippet
snippet mailto "XHTML <a mailto: >"
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
endsnippet
snippet base "XHTML <base>"
<base href="$1"${2: target="$3"}${TM_XHTML}>
endsnippet
snippet body "XHTML <body>"
<body id="${1:${TM_FILENAME/(.*)\..*/\L$1/}}"${2: onload="$3"}>
$0
</body>
endsnippet
snippet div "XHTML <div>"
<div${1: id="${2:name}"}>
${0:$TM_SELECTED_TEXT}
</div>
endsnippet
snippet form "XHTML <form>"
<form action="${1:${TM_FILENAME/(.*?)\..*/$1_submit/}}" method="${2:get}" accept-charset="utf-8">
$0
<p><input type="submit" value="Continue →"${TM_XHTML}></p>
</form>
endsnippet
snippet h1 "XHTML <h1>"
<h1 id="${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}">${1:$TM_SELECTED_TEXT}</h1>
endsnippet
snippet head "XHTML <head>"
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"${TM_XHTML}>
<title>${1:${TM_FILENAME/((.+)\..*)?/(?2:$2:Page Title)/}}</title>
$0
</head>
endsnippet
snippet link "XHTML <link>"
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"${TM_XHTML}>
endsnippet
snippet meta "XHTML <meta>"
<meta name="${1:name}" content="${2:content}"${TM_XHTML}>
endsnippet
snippet scriptsrc "XHTML <script src...>"
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script>
endsnippet
snippet script "XHTML <script>"
<script type="text/javascript" charset="utf-8">
$0
</script>
endsnippet
snippet style "XHTML <style>"
<style type="text/css" media="screen">
$0
</style>
endsnippet
snippet table "XHTML <table>"
<table border="${1:0}"${2: cellspacing="${3:5}" cellpadding="${4:5}"}>
<tr><th>${5:Header}</th></tr>
<tr><td>${0:Data}</td></tr>
</table>
endsnippet
snippet title "XHTML <title>"
<title>${1:${TM_FILENAME/((.+)\..*)?/(?2:$2:Page Title)/}}</title>
endsnippet

View File

@ -4,15 +4,34 @@
import urllib
import re
from xml.etree import ElementTree
from xml.parsers.expat import ExpatError
import htmlentitydefs
_UNESCAPE = re.compile(ur'&\w+?;', re.UNICODE)
def unescape(s):
if s is None:
return ""
def fixup(m):
ent = m.group(0)[1:-1]
print ent
return unichr(htmlentitydefs.name2codepoint[ent])
try:
return _UNESCAPE.sub(fixup,s.decode("utf-8")).encode("utf-8")
except:
print s.decode("utf-8")
def parse_content(c):
try:
data = ElementTree.fromstring(c)[0]
rv = {}
for k,v in zip(data[::2], data[1::2]):
rv[k.text] = v.text
rv[k.text] = unescape(v.text)
return rv
except ExpatError:
print " Syntax Error"
return None
def fetch_snippets(name):
base_url = "http://svn.textmate.org/trunk/Bundles/" + name + ".tmbundle/"
@ -28,11 +47,13 @@ def fetch_snippets(name):
if name == "..":
continue
name = name.rsplit('.', 1)[0] # remove Extension
name = unescape(name.rsplit('.', 1)[0]) # remove Extension
print "Fetching data for Snippet '%s'" % name
content = urllib.urlopen(snippet_idx + link).read()
rv.append((name, parse_content(content)))
cont = parse_content(content)
if cont:
rv.append((name, cont))
return rv
@ -44,7 +65,7 @@ def write_snippets(snip_descr, f):
continue
f.write('snippet %s "%s"\n' % (d["tabTrigger"], name))
f.write(d["content"] + "\n")
f.write(d["content"].encode("utf-8") + "\n")
f.write("endsnippet\n\n")