RSS Element,demiblog Class,Language,Link,Title,Description channel,,en_GB,http://tobyinkster.co.uk/tag/software/,"Articles Tagged with ""Software""", item,A,en_GB,http://tobyinkster.co.uk/article/editor-wrapper/,editor-wrapper,"====

The situation: you are a web author, surfing some of
your own pages and spot a mistake. You hit the “View Source” button in
your browser, fix the mistake and go on surfing. Later on you come back to
that page with the mistake and the mistake is still there! Why? Because
you were editing the file in your browser’s cache, not the original
file!

This situation annoyed me so much that I decided to do something about
it!

Stage One

Firstly, you assign the source-code viewer for your browser to be, instead
of your regular text editor, to be the following Perl script:

#!/usr/bin/perl   
  1. options
    $editor = $ENV{‘XEDITOR’}||’/usr/bin/nedit’;
    $settings = $ENV{‘HOME’}.’/.editor-wrapper’;
    die “Should be called with a web page as an argument\n”
    unless ($file = shift @ARGV);
  1. search for special line
    open(FILE,$file);
    READLINE: while (<FILE>)
    {
    chomp;
    last READLINE if /^<!—…
" item,A,en_GB,http://tobyinkster.co.uk/article/html2highlight/,html2highlight,"====

html2highlight is a a script that converts an HTML or any other XML-like SGML document into a HTML page showing the document’s source code with naïve syntax highlighting. The output document requires a CSS-capable browser.

The colours for the syntax highlighting are inspired by Mozilla’s “View Source” function.

Although it is a Perl script, it is reasonably efficient. It typically takes about 1 minute to convert a 100KB document on my 400MHz Pentium Celery with 256MB RAM. Output documents are about 2 to 5 times the size of the original.

Examples