See Ctext highlighting widget for a complete solution that works well.
Also see Jeffrey Hobbs Tcl source code to HTML compatible format converter. Does some intelligent highlighting at [L1 ].