Creating a glossary in TWiki

Updated: Click here

TWiki is a great wiki application that has flexibility in creating most types of document management system, let alone project management. Just recently, we require a glossary to ensure we know what we are referring to. Very much similar to what Wikipedia has for Category. TWiki’s FilterPlugin allows such an automated process.

Consider the following in a TWiki topic using TWiki’s text formatting rules:

---+++ A
$ <a name="Application">Application</a> : Of or being a computer program designed for a specific task or use.

---+++ H
$ <a name="Hardware">Hardware</a> : Machines and other physical equipment directly involved in performing an industrial, technological, or military function.

---+++ S
$ <a name="Software">Software</a> : The programs, routines, and symbolic languages that control the functioning of the hardware and direct its operation.

To generate a glossary/index out of it, we must extract the relevant text out of the topic, which FilterPlugin happily does it using %EXTRACT%.

%EXTRACT{ topic="%TOPIC%" expand="off" pattern="^\s{3}\$\s\<a\sname=\"(.*?)\"\>(.*?)\</a\>\s:\s(.*?)[\r\n]+” format=”$1 - $2 :: ” skip=”$3″ }%

What it does is grabbing the content and attribute of the a html tags, and put it in the following format, Application - Application :: Hardware - Hardware :: Software - Software :: . We don’t need the description of the term, so we skip it.

Now, all we need is to put that through %MAKEINDEX% to generate the glossary.

%MAKEINDEX{ "%EXTRACT{ topic="%TOPIC%" expand="off" pattern="^\s{3}\$\s\<a\sname=\"(.*?)\"\>(.*?)\</a\>\s:\s(.*?)[\r\n]+” format=”$1;$2@” }%” split=”@” pattern=”(.*);(.*)” format=”[[#$1][$2]]” }%

For %EXTRACT to work with %MAKEINDEX%, 1) the format of %EXTRACT% output must be slightly changed, 2) let %MAKEINDEX% know where a new definition starts through using split, 3) re-define the pattern of %EXTRACT% output, 4) and define the final output format of %MAKEINDEX%.

That’s it really! You can check out the output here!

Let your imaginations run wild!

0 Responses to “Creating a glossary in TWiki”


  1. No Comments
  1. 1 Update on creating a glossary in TWiki at MuSMo - Free Music

Leave a Reply