# Encoding: UTF-8

[{beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire \"\#{ENV['TM_BUNDLE_SUPPORT']}/tminclude.rb\"\nTextMate::Includes.instance.include_command\n",
  input: "none",
  keyEquivalent: "^@i",
  name: "Add Persistent Include",
  output: "afterSelectedText",
  scope: "text.html",
  uuid: "0D814247-7A00-46EE-A2A4-45FBBF4B1181"},
 {beforeRunningCommand: "nop",
  bundleUUID: "467B298F-6227-11D9-BFB1-000D93589AF6",
  command: 
   "#!/usr/bin/env ruby\nrequire \"\#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion\"\nTextmateCodeCompletion.go!",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "~",
  name: "CodeCompletion HTML Attributes",
  output: "insertAsSnippet",
  scope: 
   "text.html punctuation.definition.tag -source, text.html meta.tag -entity.other.attribute-name -source",
  uuid: "CBD82CF3-74E9-4E7A-B3F6-9348754EB5AA"},
 {beforeRunningCommand: "nop",
  bundleUUID: "467B298F-6227-11D9-BFB1-000D93589AF6",
  command: 
   "#!/usr/bin/env ruby\nrequire \"\#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion\"\nTextmateCodeCompletion.go!\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "~",
  name: "CodeCompletion HTML Tags",
  output: "insertAsSnippet",
  scope: 
   "text.html -entity.other.attribute-name -string.quoted, invalid.illegal.incomplete.html",
  uuid: "3463E85F-F500-49A0-8631-D78ED85F9D60"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n$KCODE = 'U'\n\n$char_to_entity = { }\nFile.open(\"\#{ENV['TM_BUNDLE_SUPPORT']}/entities.txt\").read.scan(/^(\\d+)\\t(.+)$/) do |key, value|\n  $char_to_entity[[key.to_i].pack('U')] = value\nend\n\ndef encode (text)\n  text.gsub(/[^\\x00-\\x7F]|[\"'<>&]/) do |ch|\n    ent = $char_to_entity[ch]\n    ent ? \"&\#{ent};\" : sprintf(\"&#x%02X;\", ch.unpack(\"U\")[0])\n  end\nend\n\nprint encode(STDIN.read)\n",
  fallbackInput: "character",
  input: "selection",
  keyEquivalent: "@&",
  name: "Convert Character / Selection to Entities",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "3DD8406C-A116-11D9-A5A2-000D93C8BE28"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n$KCODE = 'U'\n\n$char_to_entity = { }\nFile.open(\"\#{ENV['TM_BUNDLE_SUPPORT']}/entities.txt\").read.scan(/^(\\d+)\\t(.+)$/) do |key, value|\n  $char_to_entity[[key.to_i].pack('U')] = value\nend\n\ndef encode (text)\n  text.gsub(/[^\\x00-\\x7F]|[\"'<>&]/) do |ch|\n    ent = $char_to_entity[ch]\n    ent ? \"&\#{ent};\" : sprintf(\"&#x%02X;\", ch.unpack(\"U\")[0])\n  end\nend\n\nSTDIN.read.scan(/(?x)\n\n    ( <\\?(?:[^?]*|\\?(?!>))*\\?>\n    | <!-- (?m:.*?) -->\n    | <\\/? (?i:a|abbr|acronym|address|applet|area|b|base|basefont|bdo|big|blockquote|body|br|button|caption|center|cite|code|col|colgroup|dd|del|dfn|dir|div|dl|dt|em|fieldset|font|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|hr|html|i|iframe|img|input|ins|isindex|kbd|label|legend|li|link|map|menu|meta|noframes|noscript|object|ol|optgroup|option|p|param|pre|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|ul|var)\\b\n        (?:[^>\"']|\"[^\"]*\"|'[^']*')*\n      >\n    | &(?:[a-zA-Z0-9]+|\\#[0-9]+|\\#x[0-9a-fA-F]+);\n    )\n    |([^<&]+|[<&])\n\n  /x) do |tag, text|\n  print tag.to_s, encode(text.to_s)\nend\n",
  fallbackInput: "character",
  input: "selection",
  keyEquivalent: "@&",
  name: "Convert Character / Selection to Entities Excl. Tags",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "43C9E8AE-3E53-4B82-A1AF-56697BB3EF09"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n$KCODE = 'U'\n\n$entity_to_char = { }\nFile.open(\"\#{ENV['TM_BUNDLE_SUPPORT']}/entities.txt\").read.scan(/^(\\d+)\\t(.+)$/) do |key, value|\n  $entity_to_char[value] = [key.to_i].pack('U')\nend\n\nres = STDIN.read.gsub(/&(?:([a-z0-9]+)|#([0-9]+)|#x([0-9A-F]+));/i) do |m|\n  if $1 then\n    $entity_to_char[$1] || m\n  else\n    [$2 ? $2.to_i : $3.hex].pack(\"U\")\n  end\nend\n\nprint res\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "@&",
  name: "Decode Entities in Line / Selection",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "C183920D-A126-11D9-A5A2-000D93C8BE28"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n#\n# Lookup current word as a tag name on w3c.org\n#\n# The mapping below was generated using:\n# ruby -e 'STDOUT << \"$tags = {\\n\" << `curl -s http://www.w3.org/TR/html4/index/elements.html`.scan(%r{<td title=\"Name\"><a href=\"(.*?)\">\\n?(.*?)</a></td>}).map { |e| \"  \\\"\#{e[1]}\\\"\".ljust(14) + \" => \\\"\#{e[0]}\\\"\" }.join(\",\\n\") << \"\\n}\\n\"'\n\n$tags = {\n  \"A\"          => \"../struct/links.html#edef-A\",\n  \"ABBR\"       => \"../struct/text.html#edef-ABBR\",\n  \"ACRONYM\"    => \"../struct/text.html#edef-ACRONYM\",\n  \"ADDRESS\"    => \"../struct/global.html#edef-ADDRESS\",\n  \"APPLET\"     => \"../struct/objects.html#edef-APPLET\",\n  \"AREA\"       => \"../struct/objects.html#edef-AREA\",\n  \"B\"          => \"../present/graphics.html#edef-B\",\n  \"BASE\"       => \"../struct/links.html#edef-BASE\",\n  \"BASEFONT\"   => \"../present/graphics.html#edef-BASEFONT\",\n  \"BDO\"        => \"../struct/dirlang.html#edef-BDO\",\n  \"BIG\"        => \"../present/graphics.html#edef-BIG\",\n  \"BLOCKQUOTE\" => \"../struct/text.html#edef-BLOCKQUOTE\",\n  \"BODY\"       => \"../struct/global.html#edef-BODY\",\n  \"BR\"         => \"../struct/text.html#edef-BR\",\n  \"BUTTON\"     => \"../interact/forms.html#edef-BUTTON\",\n  \"CAPTION\"    => \"../struct/tables.html#edef-CAPTION\",\n  \"CENTER\"     => \"../present/graphics.html#edef-CENTER\",\n  \"CITE\"       => \"../struct/text.html#edef-CITE\",\n  \"CODE\"       => \"../struct/text.html#edef-CODE\",\n  \"COL\"        => \"../struct/tables.html#edef-COL\",\n  \"COLGROUP\"   => \"../struct/tables.html#edef-COLGROUP\",\n  \"DD\"         => \"../struct/lists.html#edef-DD\",\n  \"DEL\"        => \"../struct/text.html#edef-del\",\n  \"DFN\"        => \"../struct/text.html#edef-DFN\",\n  \"DIR\"        => \"../struct/lists.html#edef-DIR\",\n  \"DIV\"        => \"../struct/global.html#edef-DIV\",\n  \"DL\"         => \"../struct/lists.html#edef-DL\",\n  \"DT\"         => \"../struct/lists.html#edef-DT\",\n  \"EM\"         => \"../struct/text.html#edef-EM\",\n  \"FIELDSET\"   => \"../interact/forms.html#edef-FIELDSET\",\n  \"FONT\"       => \"../present/graphics.html#edef-FONT\",\n  \"FORM\"       => \"../interact/forms.html#edef-FORM\",\n  \"FRAME\"      => \"../present/frames.html#edef-FRAME\",\n  \"FRAMESET\"   => \"../present/frames.html#edef-FRAMESET\",\n  \"H1\"         => \"../struct/global.html#edef-H1\",\n  \"H2\"         => \"../struct/global.html#edef-H2\",\n  \"H3\"         => \"../struct/global.html#edef-H3\",\n  \"H4\"         => \"../struct/global.html#edef-H4\",\n  \"H5\"         => \"../struct/global.html#edef-H5\",\n  \"H6\"         => \"../struct/global.html#edef-H6\",\n  \"HEAD\"       => \"../struct/global.html#edef-HEAD\",\n  \"HR\"         => \"../present/graphics.html#edef-HR\",\n  \"HTML\"       => \"../struct/global.html#edef-HTML\",\n  \"I\"          => \"../present/graphics.html#edef-I\",\n  \"IFRAME\"     => \"../present/frames.html#edef-IFRAME\",\n  \"IMG\"        => \"../struct/objects.html#edef-IMG\",\n  \"INPUT\"      => \"../interact/forms.html#edef-INPUT\",\n  \"INS\"        => \"../struct/text.html#edef-ins\",\n  \"ISINDEX\"    => \"../interact/forms.html#edef-ISINDEX\",\n  \"KBD\"        => \"../struct/text.html#edef-KBD\",\n  \"LABEL\"      => \"../interact/forms.html#edef-LABEL\",\n  \"LEGEND\"     => \"../interact/forms.html#edef-LEGEND\",\n  \"LI\"         => \"../struct/lists.html#edef-LI\",\n  \"LINK\"       => \"../struct/links.html#edef-LINK\",\n  \"MAP\"        => \"../struct/objects.html#edef-MAP\",\n  \"MENU\"       => \"../struct/lists.html#edef-MENU\",\n  \"META\"       => \"../struct/global.html#edef-META\",\n  \"NOFRAMES\"   => \"../present/frames.html#edef-NOFRAMES\",\n  \"NOSCRIPT\"   => \"../interact/scripts.html#edef-NOSCRIPT\",\n  \"OBJECT\"     => \"../struct/objects.html#edef-OBJECT\",\n  \"OL\"         => \"../struct/lists.html#edef-OL\",\n  \"OPTGROUP\"   => \"../interact/forms.html#edef-OPTGROUP\",\n  \"OPTION\"     => \"../interact/forms.html#edef-OPTION\",\n  \"P\"          => \"../struct/text.html#edef-P\",\n  \"PARAM\"      => \"../struct/objects.html#edef-PARAM\",\n  \"PRE\"        => \"../struct/text.html#edef-PRE\",\n  \"Q\"          => \"../struct/text.html#edef-Q\",\n  \"S\"          => \"../present/graphics.html#edef-S\",\n  \"SAMP\"       => \"../struct/text.html#edef-SAMP\",\n  \"SCRIPT\"     => \"../interact/scripts.html#edef-SCRIPT\",\n  \"SELECT\"     => \"../interact/forms.html#edef-SELECT\",\n  \"SMALL\"      => \"../present/graphics.html#edef-SMALL\",\n  \"SPAN\"       => \"../struct/global.html#edef-SPAN\",\n  \"STRIKE\"     => \"../present/graphics.html#edef-STRIKE\",\n  \"STRONG\"     => \"../struct/text.html#edef-STRONG\",\n  \"STYLE\"      => \"../present/styles.html#edef-STYLE\",\n  \"SUB\"        => \"../struct/text.html#edef-SUB\",\n  \"SUP\"        => \"../struct/text.html#edef-SUP\",\n  \"TABLE\"      => \"../struct/tables.html#edef-TABLE\",\n  \"TBODY\"      => \"../struct/tables.html#edef-TBODY\",\n  \"TD\"         => \"../struct/tables.html#edef-TD\",\n  \"TEXTAREA\"   => \"../interact/forms.html#edef-TEXTAREA\",\n  \"TFOOT\"      => \"../struct/tables.html#edef-TFOOT\",\n  \"TH\"         => \"../struct/tables.html#edef-TH\",\n  \"THEAD\"      => \"../struct/tables.html#edef-THEAD\",\n  \"TITLE\"      => \"../struct/global.html#edef-TITLE\",\n  \"TR\"         => \"../struct/tables.html#edef-TR\",\n  \"TT\"         => \"../present/graphics.html#edef-TT\",\n  \"U\"          => \"../present/graphics.html#edef-U\",\n  \"UL\"         => \"../struct/lists.html#edef-UL\",\n  \"VAR\"        => \"../struct/text.html#edef-VAR\"\n}\n\ndef request_tag_name (default_tag = \"body\")\n  res, tag = %x{ \"$TM_SUPPORT_PATH/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog\" \\\n    inputbox --float --title 'Documentation for Tag' \\\n    --informative-text 'What tag would you like to lookup?' \\\n    --text '\#{default_tag}' --button1 'Lookup' --button2 'Cancel' \\\n    --button3 'Show All Tags'\n  }.split(\"\\n\")\n  case res.to_i\n    when 1 then $tags[tag.to_s.upcase] || \"elements.html\"\n    when 2 then abort \"<script>window.close()</script>\"\n    when 3 then \"elements.html\"\n  end\nend\n\nline, col = ENV[\"TM_CURRENT_LINE\"].to_s, ENV[\"TM_LINE_INDEX\"].to_i\ntag = line =~ /\\A.{0,\#{col}}<\\s*(\\w+)/ ? $1 : ENV[\"TM_CURRENT_WORD\"].to_s\n\npath = $tags[tag.upcase] || request_tag_name(tag)\nurl  = \"http://www.w3.org/TR/html4/index/\" + path\nputs \"<meta http-equiv='Refresh' content='0;URL=\#{url}'>\"\n",
  input: "none",
  keyEquivalent: "^h",
  name: "Documentation for Tag",
  output: "showAsHTML",
  scope: "text.html, text.html entity.name.tag",
  uuid: "637CEA2B-578C-429C-BB74-30E8D42BFA22"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n\ndef e_js(str)\n  str.gsub(/(?=[\\\\\"])/, '\\\\').gsub(/\\n/, '\\n').gsub(/[@.\\/]/) { |ch| sprintf('\\\\%03o', ch[0]) }\nend\n\ndef rot_13(str)\n  str.tr('A-Za-z', 'N-ZA-Mn-za-m')\nend\n\nprint %{<script type=\"text/javascript\">document.write(\n\"\#{e_js(rot_13(STDIN.read))}\".replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<=\"Z\"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));\n</script>}\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "@&",
  name: "Encrypt Line / Selection (ROT 13)",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "9B13543F-8356-443C-B6E7-D9259B604927"},
 {beforeRunningCommand: "nop",
  command: 
   ". \"$TM_SUPPORT_PATH/lib/webpreview.sh\"\nhtml_header \"About Persistent Includes\" \"HTML\"\nMarkdown.pl <<'EOF'|SmartyPants.pl\nThe \"Add Persistent Include\" command allows you to embed an external file inside your HTML document. This inclusion is handled by TextMate itself. Once you've added the include statement, use the \"Update Document\" command to refresh any included files.\n\nIncluding Files\n---------------\n\nAn inclusion is done using a special HTML comment:\n\n    <!-- #tminclude \"footer.html\" -->\n    <!-- end tminclude -->\n\nOnce you've updated the document, the contents are pulled inside the inclusion markup:\n\n    <!-- #tminclude \"footer.html\" -->\n    <div class=\"footer\">Copyright (c) 2006, WebDesignCorp.</div>\n    <!-- end tminclude -->\n\nNote: Included documents are also processed for additional inclusions and placeholders.\n\nInclude Parameters\n------------------\n\nYou can optionally specify parameters for the included file. Parameters are provided following the filename.\n\n    <!-- #tminclude \"header.html\" #title#=\"Home Page\" -->\n    <!-- end tminclude -->\n\nWith a header.html file that looks like this:\n\n\t<h1 class=\"header\">#title#</h1>\n\nProducing:\n\n    <!-- #tminclude \"header.html\" #title#=\"Home Page\" -->\n\t<h1 class=\"header\">Home Page</h1>\n    <!-- end tminclude -->\n\nPlaceholders\n------------\n\nThe update command also processes document \"placeholders\". Placeholders are written in this format:\n\n\t#variable#\n\nThe following placeholders are available:\n\n<table class=\"pro_table\" border=\"0\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\">\n<tr><th>Placeholder</th><th>Example Result</th></tr>\n<tr><td><tt>#abbrevdate#    </tt></td><td>Abbreviated date: Sun, Aug 15, 2006</td></tr>\n<tr><td><tt>#basename#      </tt></td><td>Filename without extension.</td></tr>\n<tr><td><tt>#compdate#      </tt></td><td>Compact date: 15-Aug-06</td></tr>\n<tr><td><tt>#creationdate#  </tt></td><td>Creation date: 15-Aug-06</td></tr>\n<tr><td><tt>#creationtime#  </tt></td><td>Creation time:  1:20 PM</td></tr>\n<tr><td><tt>#docsize#       </tt></td><td>Resulting document length in bytes</td></tr>\n<tr><td><tt>#dont_update#   </tt></td><td>Special: presence will prevent document updating</td></tr>\n<tr><td><tt>#filename#      </tt></td><td>Document filename</td></tr>\n<tr><td><tt>#file_extension#</tt></td><td>Document file extension</td></tr>\n<tr><td><tt>#generator#     </tt></td><td>TextMate</td></tr>\n<tr><td><tt>#gmtime#        </tt></td><td>GMT time</td></tr>\n<tr><td><tt>#localpath#     </tt></td><td>Full path to current file</td></tr>\n<tr><td><tt>#localtime#     </tt></td><td>Local computer time</td></tr>\n<tr><td><tt>#longdate#      </tt></td><td>Long Date: Tuesday, August 15, 2006</td></tr>\n<tr><td><tt>#modifieddate#  </tt></td><td>Modified date: 15-Aug-06</td></tr>\n<tr><td><tt>#modifiedtime#  </tt></td><td>Modified time:  1:20 PM</td></tr>\n<tr><td><tt>#monthdaynum#   </tt></td><td>Day of Month: 15</td></tr>\n<tr><td><tt>#monthnum#      </tt></td><td>Month Number: 08</td></tr>\n<tr><td><tt>#shortdate#     </tt></td><td>Short Date: 08/15/06</td></tr>\n<tr><td><tt>#shortusername# </tt></td><td>Login name of current user</td></tr>\n<tr><td><tt>#username#      </tt></td><td>Name of current user</td></tr>\n<tr><td><tt>#yearnum#       </tt></td><td>Current Year: 2006</td></tr>\n</table>\n\nIn addition to these, all of the TextMate environment variables (those starting with a \"TM_\" prefix) are available as placeholders. For example:\n\n    #organization_name#\n\nWill populate using the `TM_ORGANIZATION_NAME` environment variable.\n\nFormatting Time\n---------------\n\nThe date-based placeholders may also specify a format that can be used to customize the date output. For example:\n\n    #gmtime %b %e, %Y# (Aug 15, 2006)\n\nPlaceholder Example\n-------------------\n\nIf you want to make that footer.html include more useful, you can use placeholders. For example:\n\n    <div class=\"footer\">Copyright (c) #yearnum#, #oragnization_name#.</div>\n\nThis would then produce the following, when included and processed:\n\n    <!-- #tminclude \"footer.html\" -->\n    <div class=\"footer\">Copyright (c) 2006, WebDesignCorp.</div>\n    <!-- end tminclude -->\n\nScripted Includes\n-----------------\n\nIt is also possible to produce included content using scripts. If the included file is a script, it is run and the output is placed inside the include block.\n\n\t<!-- #tminclude \"scripts/header.pl\" #class#=\"huge\" -->\n\t<!-- end tminclude -->\n\n.pl (Perl), .py (Python) and .rb (Ruby) scripts are currently recognized. For the above example, the \"header.pl\" script is run with the following parameters:\n\n\theader.pl (source_filename) class huge\n\nThe Perl script in this case can process the parameters like this.\n\n\t#!/usr/bin/perl\n\tmy ($filename, %args) = @ARGV;\n\tprint \"<h1 class='$args{class}'>Header for $filename</h1>\"\n\nThat would end up producing this:\n\n\t<!-- #tminclude \"scripts/header.pl\" #class#=\"huge\" -->\n\t<h1 class='huge'>Header for /path/to/example.html</h1>\n\t<!-- end tminclude -->\n\nEOF\nhtml_footer",
  input: "none",
  name: "Help: Persistent Includes",
  output: "showAsHTML",
  scope: "text.html",
  uuid: "9AFDEB2C-D9F0-423E-8211-EBB089F51F0C"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n\ndoc        = STDIN.read\nline       = ENV['TM_LINE_NUMBER'].to_i\nline_index = ENV['TM_LINE_INDEX'].to_i\n\nif ENV.has_key? 'TM_INPUT_START_LINE' then\n  line       = ENV['TM_INPUT_START_LINE'].to_i\n  line_index = ENV['TM_INPUT_START_LINE_INDEX'].to_i\nend\n\nbefore = /(.*\\n){\#{line-1}}.{\#{line_index}}/.match(doc)[0]\n\nbefore.gsub!(/<[^>]+\\/\\s*>/i, '')\n\n# remove all self-closing tags\nif ENV.has_key?('TM_HTML_EMPTY_TAGS') then\n  empty_tags = ENV['TM_HTML_EMPTY_TAGS']\n  before.gsub!(/<(\#{empty_tags})\\b[^>]*>/i, '')\nend\n\n# remove all comments\nbefore.gsub!(/<!--.*?-->/m, '')\n\nstack = [ ]\nbefore.scan(/<\\s*(\\/)?\\s*(\\w[\\w:-]*)[^>]*>/) do |m|\n  if m[0].nil? then\n    stack << m[1]\n  else\n    until stack.empty? do\n      close_tag = stack.pop\n      break if close_tag == m[1]\n    end\n  end\nend\n\nif stack.empty? then\n  %x{ osascript -e beep &>/dev/null & }\nelse\n  print \"</\#{stack.pop}>\"\nend",
  input: "document",
  keyEquivalent: "~@.",
  name: "Insert Close Tag",
  output: "afterSelectedText",
  uuid: "0658019F-3635-462E-AAC2-74E4FE508A9B"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby -w\nSUPPORT = ENV['TM_SUPPORT_PATH']\nDIALOG = SUPPORT + '/bin/tm_dialog'\n\nrequire \"\#{SUPPORT}/lib/osx/plist\"\nrequire \"\#{SUPPORT}/lib/escape\"\n\nentities = [ ]\nFile.read(\"\#{ENV['TM_BUNDLE_SUPPORT']}/entities.txt\").scan(/^(\\d+)\\t(.+)$/) do |key, value|\n  char = [key.to_i].pack('U')\n  entities << { 'display' => \"\#{value} (\#{char})\", 'char' => char, 'entity' => value }\nend\n\nplist = { 'entities' => entities, 'insertAsEntity' => true }.to_plist\nopen(\"|\#{e_sh DIALOG} -cm 'Insert Entity'\", 'w+') do |io|\n  io << plist; io.close_write\n\n  res = OSX::PropertyList.load(io.read)['result']\n  abort if res.nil?\n\n  if res['asEntity'].to_i == 1\n    print '&' + res['returnArgument'].first['entity'] + ';'\n  else\n    print res['returnArgument'].first['char']\n  end\nend\n",
  input: "none",
  keyEquivalent: "@&",
  name: "Insert Entity…",
  output: "afterSelectedText",
  scope: "text.html",
  uuid: "89E5CC0A-3EFF-4DEF-A299-2E9651DE6529"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n#\n# This script will expand the current word into: <word></word>\n# It will recognize HTML 4.0 tags that need no close tag.\n#\n# With no current word, it will insert: <p></p> and allows you\n# to overwrite the tag name and add potential arguments.\n#\n# The result is inserted as a snippet, so it's\n# possible to tab through the place holders.\n\n# single tags\nsingle_no_arg = /^(?:br|hr)$/i\nsingle        = /^(?:img|meta|link|input|base|area|col|frame|param)$/i\n\n# we are not in HTML mode, so let’s scrap the above hardcoded tag lists\nunless ENV.has_key? 'TM_HTML_EMPTY_TAGS' then\n  single_no_arg = /(?=not)possible/\n  single        = /(?=not)possible/\nend\n\n# handle the case where caret is in the middle of a word, assume only the left part is the tag\nindex = ENV['TM_LINE_INDEX'].to_i - ENV['TM_INPUT_START_LINE_INDEX'].to_i\ntag, suffix = STDIN.read, ''\nif index < tag.length && !ENV['TM_SELECTED_TEXT']\n  tag, suffix = tag[0...index], tag[index..-1]\nend\n\nxhtml = ENV['TM_XHTML'].to_s\n\nprint case tag\n  when single_no_arg then \"<\#{tag}\#{xhtml}>\"\n  when single then        \"<\#{tag} $1\#{xhtml}>\"\n  when '' then            \"<${1:\#{ENV['TM_DEFAULT_TAG'] || 'p'}}>$2</${1/\\\\s.*//}>\"\n  else                    \"<\#{tag}>$1</\#{tag.strip[/^\\S+/]}>\"\nend\n\nprint suffix\n",
  fallbackInput: "word",
  input: "selection",
  keyEquivalent: "^<",
  name: "Insert Open/Close Tag (With Current Word)",
  output: "insertAsSnippet",
  uuid: "2ED44A32-C353-447F-BAE4-E3522DB6944D"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "#!/usr/bin/env ruby -wKU\n# \n# Open Document in Running Browser(s)\n# \n# Now supports multiple running versions of a single browser along\n# with a range of new/old browsers. Bring back support for Firefox.\n# \n# Options: Set TM_PROJECT_SITEURL in your TM Project Window Info Button\n# in the following form: \"http://example.com/\"\n\nrequire \"\#{ENV['TM_SUPPORT_PATH']}/lib/escape.rb\"\n\nif ENV['TM_PROJECT_SITEURL']\n  url = \"\#{ENV['TM_PROJECT_SITEURL']}\" + ENV['TM_FILEPATH'].sub(/^\#{Regexp.escape(ENV['TM_PROJECT_DIRECTORY'])}\\//, '') \nelse\n  url = \"file://\#{ENV['TM_FILEPATH']}\"\nend\n\nproclist = `ps -x -o command`\nactive = []\nos = `defaults read /System/Library/CoreServices/SystemVersion ProductVersion`\n\nbrowsers = %w[ Safari OmniWeb Camino Shiira firefox-bin Xyle\\ scope Opera Internet\\ Explorer flock-bin iCab Sunrise seamonkey-bin navigator-bin ].join('|')\n\n# Build paths to each active browser\n#\n# Notes:\n#   - 'WebKit' look ahead is to rule it out so we can use the working\n#      rule below.\n#   - 'LaunchCFMApp' portion is so iCab works.\nactive = proclist.scan(%r{^(?:/.*LaunchCFMApp )?(/.*\\.app)(?=/Contents/MacOS/(?:\#{browsers})\\b(?!.*WebKit))})\n\n# Special check for WebKit as it appears as Safari\n# Note: Only supports one running instance of WebKit, picked at random.\nif proclist =~ %r{/Contents/MacOS/Safari.*WebKit}\n  active << \"WebKit\"\nend\n\n# TODO: Change when Leopard Only\n# On Leopard use the -g option to open in background.\nif os =~ /^10\\.(5|6)/\n  active.each {|p| `open -g -a \#{e_sh(p)} \#{e_sh(url)}` }\nelse\n  active.each {|p| `open -a \#{e_sh(p)} \#{e_sh(url)}` }\nend",
  input: "none",
  name: "Open Document in Running Browser(s)",
  output: "discard",
  scope: "text.html",
  uuid: "970EE6B4-A091-11D9-A5A2-000D93C8BE28"},
 {beforeRunningCommand: "saveActiveFile",
  command: 
   "###\tRefresh All Active Browsers - OmniWeb, Safari, Firefox & IE\n### v1.0. 2005-03-29\n###\n\n# Check if Internet Explorer is running, if so refresh\nps -xc|grep -sq \"Internet Explorer\" && osascript -e 'tell app \"Internet Explorer\"' -e 'activate' -e 'OpenURL \"JavaScript:window.location.reload();\" toWindow -1' -e 'end tell'\n\n# Check if OmniWeb is running, if so refresh\nps -xc|grep -sq OmniWeb && osascript -e 'tell app \"OmniWeb\"' -e 'activate' -e 'reload first browser' -e 'end tell'\n\n# Check if Firefox is running, if so refresh\nps -xc|grep -sqi firefox && osascript <<'APPLESCRIPT'\n   tell app \"Firefox\" to activate\n   tell app \"System Events\"\n      if UI elements enabled then\n         keystroke \"r\" using command down\n         -- Fails if System Preferences > Universal access > \"Enable access for assistive devices\" is not on \n      else\n         -- Comment out until Firefox regains Applescript support\n         -- tell app \"Firefox\" to Get URL \"JavaScript:window.location.reload();\" inside window 1\n         -- Fails if Firefox is set to open URLs from external apps in new tabs.\n      end if\n   end tell\nAPPLESCRIPT\n\n# Check if Safari is running, if so refresh\nps -xc|grep -sq Safari && osascript -e 'tell app \"Safari\"' -e 'activate' -e 'do JavaScript \"window.location.reload();\" in first document' -e 'end tell'\n\n# Check if Camino is running, if so refresh \nps -xc|grep -sq Camino && osascript -e 'tell app \"Camino\"' -e 'activate' -e 'tell app \"System Events\" to keystroke \"r\" using {command down}' -e 'end tell'\n",
  input: "none",
  keyEquivalent: "@r",
  name: "Refresh Running Browser(s)",
  output: "discard",
  scope: "text.html, source.css",
  uuid: "B8651C6E-A05E-11D9-86AC-000D93C8BE28"},
 {beforeRunningCommand: "nop",
  command: 
   "## Strip HTML and PHP tags from the selected text\nphp -r 'echo strip_tags( file_get_contents(\"/dev/stdin\") );'\n\n###  If you want to keep a particular tag, such as <p> comment the above line and uncomment the next line\n# php -r 'echo strip_tags( file_get_contents(\"/dev/stdin\"), \"<p>\" );'\n### end",
  fallbackInput: "document",
  input: "selection",
  keyEquivalent: "",
  name: "Strip HTML Tags from Document / Selection",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "20D760B5-A127-11D9-A5A2-000D93C8BE28"},
 {beforeRunningCommand: "nop",
  captureFormatString: "$3",
  capturePattern: "line (\\d+) column (\\d+) - (.*?)$",
  command: 
   "#!/usr/bin/env ruby -wKU\n\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'\nrequire ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes.rb'\n\nresult = `\"${TM_TIDY:-tidy}\" -f /tmp/tm_tidy_errors -iq -utf8 \\\n          -wrap 0 --tab-size $TM_TAB_SIZE --indent-spaces $TM_TAB_SIZE \\\n\t\t--indent yes \\\n          ${TM_XHTML:+-asxhtml --output-xhtml yes} \\\n          ${TM_SELECTED_TEXT:+--show-body-only yes} \\\n          --enclose-text yes \\\n          --doctype strict \\\n\t\t--wrap-php no \\\n          --tidy-mark no`\nstatus = $?.exitstatus\n\nat_exit { File.unlink('/tmp/tm_tidy_errors') } # Clean up error log\n\nif status == 2 # Errors\n\n  msg = \"Errors: \" + File.read('/tmp/tm_tidy_errors')\n  TextMate.exit_show_tool_tip msg\n\nelsif status == 1 # Warnings - use output but also display notification with warnings\n  \n  log = File.read('/tmp/tm_tidy_errors').to_a.select do |line|\n    ! (ENV['TM_SELECTED_TEXT'] and (line.include?('Warning: missing <!DOCTYPE> declaration') or line.include?(\"Warning: inserting missing 'title' element\")))\n  end.join rescue nil\n  \n  unless log.empty?\n    options = {\n      :title   => \"Tidy Warnings\",\n      :summary => \"Warnings for tidying your document (press escape to close):\",\n      :log     => log\n    }\n    TextMate::UI.simple_notification(options)\n  end\n\nend\n\nif ENV['TM_SOFT_TABS'] == \"YES\"\n  print result\nelse\n  in_pre = false\n  result.each_line do |line|\n    unless in_pre\n      tab_size = ENV[\"TM_TAB_SIZE\"].to_i\n      space, text = /( *)(.*)/m.match(line)[1..2]\n      line = \"\\t\" * (space.length / tab_size).floor + \" \"  * (space.length % tab_size) + text\n    end\n    \n    print line\n  \n    in_pre = true  if line.include?(\"<pre>\")\n    in_pre = false if line.include?(\"</pre>\")\n  end\nend",
  input: "selection",
  keyEquivalent: "^H",
  lineCaptureRegister: "1",
  name: "Tidy",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "45F92B81-6F0E-11D9-A1E4-000D9332809C"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\n\nprint STDIN.read.gsub(/([^a-zA-Z0-9_.-]+)/n) {\n  '%' + $1.unpack('H2' * $1.size).join('%').upcase\n}\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "@&",
  name: "URL Escape Line / Selection",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "6B024865-6095-4CE3-8EDD-DC6F2230C2FF"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire 'cgi'\nprint CGI.unescape(STDIN.read)\n",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "@&",
  name: "URL Unescape Line / Selection",
  output: "replaceSelectedText",
  scope: "text.html",
  uuid: "2C4C9673-B166-432A-8938-75A5CA622481"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby\nrequire \"\#{ENV['TM_BUNDLE_SUPPORT']}/tminclude.rb\"\nTextMate::Includes.instance.process_persistent_includes\n",
  input: "document",
  keyEquivalent: "^@u",
  name: "Update Document",
  output: "replaceDocument",
  scope: "text.html",
  uuid: "4400BCE9-20E3-426E-B1D7-2C0BCA53BCF8"},
 {beforeRunningCommand: "nop",
  command: 
   "#!/usr/bin/env ruby -wKU\nSTDOUT.sync = true\n\npage = STDIN.read\npage.gsub!(/<\\?(php|=).*?\\?>|<%.*?%>/m, '')\n\nopen('|curl -sF uploaded_file=@-\\;type=text/html http://validator.w3.org/check', 'r+') do |io|\n  io << page; io.close_write\n  while line = io.gets\n    line.gsub!(/<\\/title>/, '\\&<base href=\"http://validator.w3.org/\">')\n    line.gsub!(/Line (\\d+),? Column (\\d+)/i) do\n      \"<a href='txmt://open?line=\#$1&column=\#{$2.to_i + 1}'>\#$&</a>\"\n    end\n    puts line\n  end\nend\n",
  dontFollowNewOutput: true,
  input: "document",
  keyEquivalent: "^V",
  name: "Validate Syntax (W3C)",
  output: "showAsHTML",
  scope: "text.html",
  uuid: "3F26240E-6E4A-11D9-B411-000D93589AF6"},
 {beforeRunningCommand: "nop",
  command: 
   "perl -pe 's/[\\$`\\\\]/\\\\$&/g; s/([ \\t]*)(.+)/$1<\\${1:li}>$2<\\/\\${1\\/\\\\s.*\\/\\/}>/'",
  fallbackInput: "line",
  input: "selection",
  keyEquivalent: "^@W",
  name: "Wrap Each Selected Line in Open/Close Tag",
  output: "insertAsSnippet",
  scope: "text.html",
  uuid: "991E7EBD-F3F5-469A-BA01-DC30E04AD472"}]
