Ticket #13 (accepted enhancement)
Improved formatter
| Reported by: | dartar | Owned by: | JavaWoman |
|---|---|---|---|
| Priority: | high | Milestone: | 1.3 |
| Component: | formatters | Version: | 1.1.6.0 |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by DotMG) (diff)
While our current formatter is quite capable, it has some quirks and bugs, doesn't always generate valid XHTML (though it tries hard), and misses a few things that would be nice to have or that would enable things that would be nice to have (such as a page TOCs). The improved version presented here tries to address some of these issues.
Status
Coded as beta
What it does
- 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 (a long-standing bug!) Now improved
- better handling of nested lists so change of list "type" is actually detected and coded correctly; also produces nicely-formatted HTML code for lists and indents now, especially more readable for nested lists. New!
- escaping single & (not part of an entity) (another long-standing problem); See #410
- ability to nest one type of float within another (so a right float can contain a left float and vice versa)
- handling ids (and making them unique) as provided in embedded code, using the makeId() method;
- creating ids for headings based on content ('afterburner' type formatting so this includes originally embedded code); this code not only uses the makeId() method but also the html_entity_decode() method in PHP versions older than 4.3. See also #20
Refs
Related tickets / subtickets
Related comments moved from WikkaBugs
Wakka formatter: Indenting on first line
// indented text
elseif (preg_match("/\n([\t~]+)(-|&|([0-9a-zA-ZÄÖÜßäöü]+)\))?(\n|$)/s", $thing, $matches))
This simply doesn't match indents on the first line. I know there is a problem in the edit handler as well with indents, but even if that is fixed (working solution for that problem at WikkaBugsResolved) we still will have the problem here. -- TimoK
Fixed and implemented as part of the beta ImprovedFormatter on this site; see http://wikkawiki.org/ImprovedFormatter#hn_Better_handling_of_nested_lists_and_indents
--JavaWoman
List parsing bug?
Have a look at the source of WikkaDevelopment, you will see that tabs and unordered lists for some reasons are not correctly parsed (actually after one edit, tabs were added at the beginning of each line). I'll try to figure out why this happens... -- DarTar
Possible clue: I just stumbled over the fact that the little list of "Useful pages" at the end of the default (installation-generated) ""HomePage"" had incorrect coding: The last list item (li) was not terminated, nor was the list itself (no closing ul tag). It took me a bit of trial and error to reproduce this - but have a look at my test code at the end of SandBox (now). Originally I thought that any list at the end of a page would be unterminated, but that turned out not to be the case. Then I hit on something else: the last list element on that default ""HomePage"" (not the one here) ands with a period. My test version on SandBox now also has the last element ending in a period ... and if you look at the (HTML) page source, you'll see it is indeed an unterminated list. Somehow that ending period (maybe in combination with end-of-page?) causes the Formatter never to close the list; take that ending period away, and it works normally. I tried a few variants, to check whether it might be an odd-even problem, but no: whether the number of list items is odd or even, if the last one ends in a period, the list isn't terminated.
No difference whether it's anordered (ol) or unordered (ul) list, the formatter behaves the same way.
And, BTW, if you look at the preview when editing, the HTML source of the **preview** actually contains a lot of Wiki code that shouldn't be there!
I haven't dug in the Formatter yet to find the cause or whether end-of-page makes a difference... --JavaWoman
This is indeed an "end of page" problem: teh formatter has some code to close tags inadvertently left open, but does not do this for lists and indent (nor even fro *all* open tags). Fix coded and tested - this will be in 1.1.6.2. --JavaWoman