Skip to content

Commit

Permalink
Added preview command, largely heisted from Textile bundle
Browse files Browse the repository at this point in the history
Signed-off-by: alkemist <ld@ldaley.com>
  • Loading branch information
purp authored and ldaley committed Jun 3, 2009
1 parent 0822790 commit a4dd3c1
Show file tree
Hide file tree
Showing 3 changed files with 1,182 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Commands/Preview.tmCommand
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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>. "$TM_SUPPORT_PATH/lib/html.sh"
if [[ -z $TM_FILENAME ]]
then title="Textile as HTML"
else title="${TM_FILENAME%.*} as HTML"
fi
htmlHeader "$title" '&lt;style type="text/css"&gt;
body {
background-color: #eee;
}
.contents {
background: white;
font-family: Verdena, sans-serif;
font-size: 13px;
border: 1px #888 solid;
padding: 0 1em;
}
&lt;/style&gt;'
beginTag div 'contents'
"$TM_BUNDLE_SUPPORT/bin/Preview.rb"
endTag
htmlFooter</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^~@p</string>
<key>name</key>
<string>Preview</string>
<key>output</key>
<string>showAsHTML</string>
<key>uuid</key>
<string>EC3CA023-3BAC-446E-92E6-403353B9BA44</string>
</dict>
</plist>
10 changes: 10 additions & 0 deletions Support/bin/Preview.rb
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

begin
require 'redcloth'
rescue LoadError
$LOAD_PATH << File.join(ENV['TM_BUNDLE_SUPPORT'], 'lib')
require 'redcloth'
end

puts(RedCloth.new($stdin.readlines.join()).to_html(:textile))

0 comments on commit a4dd3c1

Please sign in to comment.