Revision [16650]
This is an old revision of AcronymFormatter made by ZzdE5p on 2007-05-31 10:29:07.
Acronym (or Abbreviation) Formatter
This is the development page for the Acronym (or Abbreviation) Formatter.
This modification allows Wikka to automatically parse known acronyms and render them as <acronym> elements with titles, for example:
CSS - FAQ - HTML
The list of acronyms can be set by the WikiAdmin in a configuration file: each time an acronym is found in the page source matching one of the entries of this file, it is automatically rendered with the appropriate markup and expanded description.
Features
Current version: 0.3 (improved regex pattern)- customizable acronym definition file;
- formatter can be disabled from config file;
- configurable REGEX pattern;
- configurable output format (abbrv or acronym);
To do
- important fix conflicts with links, WikiName WikiNames and other elements containing sequences of uppercase letters that should not be rendered as acronyms;
- improve REGEX pattern;
- support CSS classes for different kinds of acronyms;
The code
Here's the list of files that you will have to create or modify (backup the original files before making any modification)1. Modify ./formatters/wakka.php
original:
- // we're cutting the last <br />
- echo ($text);
- wakka2callback('closetags');
modified:
- // we're cutting the last <br />
- //render acronyms
- $text = $this->RenderAcronyms($text);
- echo ($text);
- wakka2callback('closetags');
2. Modify wikka.php
Add the following function in the engine, for instance immediately before the VARIABLES section:
original:
- // VARIABLES
modified:
%%(php;341)
function RenderAcronyms($text){
if (($this->GetConfigValue('enable_acronyms') 1)