Wiki syntax highlighting for the text widget
Not logged in

Version 0.65 of tkoutline contains real-time syntax highlighting for wiki-links. I'm thinking about making the syntax highlighting code general and releasing it as a separate library package. In addition to the generic syntax highlighting code, I will include wiki-like markup as an example use.

Update 06/18/02: Version 0.77 of tkoutline 1 contains code that implements the following API's. All you need is the code in lib/markup. Use "package require markup", or "package require wikimarkup" and the following commands will be available. This code depends on the wcb package 2 which can also be found in the tkoutline distribution.

API for general syntax highlighting

The code implementing this functionality can be viewed online at

The general syntax highlighting will provide a way to specify patterns (or literal text) for which tags will be automatically applied. The using application can then configure these tags with color, style, event bindings. These commands are all in the markup namespace.

Turning it on and off

Adding rules

The first way of adding a rule causes the given tag to automatically be applied when the given pattern is encountered. The second way causes the given script to be called whenever the pattern is encountered. This script can then apply multiple tags in a more complex manner. The window, start index, and end index will be appended to the script before it is called. The script is expected to return a list of the tags it applied (so they can be automatically removed when rehighlighting needs to be applied).

Removing a rule for the given pattern

Utility functions

The first function will return a list containing the start index and end index of the given tag. This is useful for event bindings. The flashTag function will configure the given tag so that any mouseover event will cause the given flashtag to be applied until the mouse leaves the tag.


The easiest way to try these examples is to run the code within tkoutline's console (console is launched with F2 key).

 # Any occurrence of the word red will be colored red
 set win textcmd    ;# Current outline text widget
 $win tag configure red -foreground red
 ::markup::addRule $win red -tag blue

# All sequences of digits will be green $win tag configure green -background green ::markup::addRule $win -regexp {\d+} -tag green

# The word "flash" will be blue until moused-over, when it will turn red $win tag configure red -foreground red $win tag configure flash -foreground blue ::markup::flashTag $win flash red ::markup::addRule $win flash -tag flash

API for wiki syntax highlighting

The code implementing this functionality can be viewed online at

These commands are all in the wikimarkup namespace.

Link markup is similar to wikit rules:

The function setLinkJumpCmd is used to configure what will happen when a wiki link is clicked. Url links are launched in an external browser when clicked.

The syntax used for style markup is different from "standard" wiki markup: