HomeRamblings  ⁄  GeneralProgramming

Ultraviolet gives new life to Syntax highlighting

Published: February 05, 2009 (almost 9 years ago)
Updated: over 2 years ago

I am tired of Google’s Syntax highlighter.  If I accidentally switch to Visual mode in the editor and do some edits and switch back to HTML mode, then I lose the class=”code” moniker and I have to go through the entire post and fix. Another drawback I have with Google Syntax highlighter is that the page renders without highlighting and then all the code listings change to syntax highlighted text a few moments later. Introducing Ultraviolet, a syntax highlighter supporting over 50 syntaxes and any TextMate theme.  Ultraviolet is based on Oniguruma, a regular expression library that comes standard with Ruby 1.9. Ultraviolet requires a little more effort for me to cut and paste, but I am definitely much happier with the end results and Wordpress no longer mungs my posts. Only real complaint I have is that I can’t read the posted code inline in HTML format (but I can read it in Visual mode!).

Ruby Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'rubygems'
require 'ramaze'
require 'maruku'
require 'sequel'

$LOAD_PATH.unshift(__DIR__)

require 'env'

require 'vendor/flickr'
require 'vendor/haml_maruku_filter'
require 'vendor/image_science_cropped_resize'

require 'model/init'
require 'controller/init'

require 'db/init' if SOCIAR.mode == :dev

r = SOCIAR.ramaze

=begin
if r.gzip
  require 'ramaze/contrib/gzip_filter'
  gzip = Ramaze::Filter::Gzip
  gzip.trait :threshold => 1
  Ramaze::Dispatcher::Action::FILTER << gzip
=end

Ramaze.start :adapter => r.adapter,
  :host => r.host,
  :port => r.port,
  :boring => r.boring

Shell Script

#!/bin/sh

### BEGIN INIT INFO
# Provides:          lm-sensors
# Required-Start:    $local_fs
# Required-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: lm-sensors
# Description:       hardware health monitoring
### END INIT INFO

. /lib/lsb/init-functions

[ -f /etc/default/rcS ] && . /etc/default/rcS
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PROGRAM=/usr/bin/sensors

test -x $PROGRAM || exit 0

case "$1" in
  start)
  log_begin_msg "Setting sensors limits"
  if [ "$VERBOSE" = "no" ]; then
    /usr/bin/sensors -s 1> /dev/null 2> /dev/null
    /usr/bin/sensors 1> /dev/null 2> /dev/null
  else
    /usr/bin/sensors -s
    /usr/bin/sensors > /dev/null
  fi
  log_end_msg $?
  ;;
  stop)
  ;;
  force-reload|restart)
  $0 start
  ;;
  *)
  log_success_msg "Usage: /etc/init.d/sensors {start|stop|restart|force-reload}"
  exit 1
esac

exit 0

Apache Config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<VirtualHost *:80>
  ServerName www.stinger.local
  ServerAdmin webmaster@localhost
  
  DocumentRoot /var/www/
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>

  ErrorLog /var/log/apache2/error.log

  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
comments powered by Disqus