Revision [8493]
This is an old revision of AdvancedFormatter made by DarTar on 2005-05-26 08:18:04.
Advanced Formatter
This is the development page (stub) for an advanced Wikka formatter.
The code written by JavaWoman (tested and ready to be installed on this server as a beta feature) addresses several issues of the current formatter. In particular, it fixes a number of small formatting bugs, and adds new important features - like automatic generation of id's for headers and forms - required for XHTML compliance and for extensions like anchors, TOC's and advanced styling through CSS.
What's new
wikka.php
- compatibility code (like mysql_real_escape) used by wakka.php when generating ids for headings;
- revised FormOpen() using makeId();
- makeId() and its supporting code:
Although - given Wikka accepts embedded HTML - it cannot be guaranteed that an id generated by this method is unique, it tries its best to make it unique:
- ids are organized into groups, with the group name used as a prefix;
- if an id is specified it is compared with other ids in the same group; if an identical id exists within the same group, a sequence suffix is added, otherwise the specified id is accepted and recorded as a member of the group
- if no id is specified (or an invalid one) an id will be generated, and given a sequence suffix if needed
For headings, it is possible to derive an id from the heading content to support this, any embedded whitespace is replaced with underscores to generate a recognizable id that will remain (mostly) constant even if new headings are inserted in a page.
The method supports embedded HTML as well: as long as the formatter passes each id found in embedded HTML through this method it can take care that the id is valid and unique. This works as follows:
- indicate an 'embedded' id with group 'embed'
- NO prefix will be added for this reserved group
- ids will be recorded and checked for uniqueness and validity
- invalid ids are replaced
- already-existing ids in the group are given a sequence suffix
The result is that as long as the already-defined id is valid and unique, it will be remain unchanged (but recorded to ensure uniqueness overall).
- a first draft of makeList() to generate a list from an array (only 'flat' arrays supported for now);
Given an array, this method builds a simple unordered or ordered list with an id. Only a (simple) array is required which will generate an unordered list; optionally id, class, type of list and an indent level can be specified. For type 'menu' an unordered list is generated but with an id in group 'menu' instead of 'ul' or 'ol': this enables the list being styled as a menu.
./formatters/wakka.php
- using single quotes wherever possible making regexes and generated HTML easier to read;
- better closing of open tags at end of document, including open indents and lists;
- escaping single & (not part of an entity);
- handling ids (and making them unique) in embedded code;
- creating ids for headings based on content ('afterburner' type so this includes originally embedded code)
The code
(forthcoming)
CategoryDevelopment