Skip to content

Commit

Permalink
Create a new Source bundle. There are two commands Source to HTML and…
Browse files Browse the repository at this point in the history
… View Source as HTML. Both of these commands use the source-highlight program now contained in the TextMate Support directory. Remove the old highlight commands from the Python Bundle, which assumed you had source-highlight installed somewhere on your system.

I've tested the command for Perl, Ruby, Python, php (not so good), C++, C, Java  Other languages are supported like Javascript, caml, sml, lua and prolog but I don't have a lot of those lying around.  Note that since I use the $TM_MODE variable the command must do a little translation from mode to the expected language, there is a case statement you can update in the command if your example fails.



git-svn-id: http://svn.textmate.org/trunk/Bundles/Source.tmbundle@966 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
bnmnetp committed May 19, 2005
0 parents commit 9c27499
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Commands/Source to HTML.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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># Using source-highlight convert source code to html
# the source-highlight command supports the following languages:
# java (for Java)
# javascript (for Javascript)
# cpp (for C/C++)
# prolog (for Prolog)
# perl (for Perl)
# php3 (for Php3)
# python (for Python)
# flex (for flex)
# changelog (for ChangeLog)
# ruby (for Ruby)
# lua (for Lua)
# caml (for Caml)
# sml (for Sml)
# log (for log files, e.g., system logs, apache and IpTables)
lang=`echo "$TM_MODE" |tr "[:upper:]" "[:lower:]"`
case "$lang" in
c++)
lang="cpp"
;;
html\ \(php\))
lang="php3"
;;
ruby\ on\ rails)
lang="ruby"
;;
ocaml)
lang="caml"
;;
esac
expand -3 | "$TM_SUPPORT_PATH"/source-highlight --line-number --src-lang=$lang --out-format=xhtml</string>
<key>input</key>
<string>document</string>
<key>keyEquivalent</key>
<string>^~h</string>
<key>name</key>
<string>Source to HTML</string>
<key>output</key>
<string>openAsNewDocument</string>
<key>scope</key>
<string>source</string>
<key>uuid</key>
<string>3DBAEC85-7D09-11D9-A1F6-000D93B6E43C</string>
</dict>
</plist>
42 changes: 42 additions & 0 deletions Commands/View Source as HTML.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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># Using source-highlight convert python code to html
# this will be better when we can use this to
# create a new document.
lang=`echo "$TM_MODE" |tr "[:upper:]" "[:lower:]"`
case "$lang" in
c++)
lang="cpp"
;;
html\ \(php\))
lang="php3"
;;
ruby\ on\ rails)
lang="ruby"
;;
ocaml)
lang="caml"
;;
esac
expand -3 | "$TM_SUPPORT_PATH"/source-highlight --line-number --src-lang=$lang --out-format=xhtml</string>
<key>input</key>
<string>document</string>
<key>keyEquivalent</key>
<string>^~h</string>
<key>name</key>
<string>View Source as HTML</string>
<key>output</key>
<string>showAsHTML</string>
<key>scope</key>
<string>source.python</string>
<key>uuid</key>
<string>88FEF123-77CA-11D9-AC33-000D93B6E43C</string>
</dict>
</plist>
15 changes: 15 additions & 0 deletions info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Source</string>
<key>ordering</key>
<array>
<string>3DBAEC85-7D09-11D9-A1F6-000D93B6E43C</string>
<string>88FEF123-77CA-11D9-AC33-000D93B6E43C</string>
</array>
<key>uuid</key>
<string>4F45FDC0-62CA-4786-9134-8BC7C1F5606F</string>
</dict>
</plist>

0 comments on commit 9c27499

Please sign in to comment.