[dokuwiki] Line-break preservation in Wiki text

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 22 Feb 2008 14:41:24 +0000

Hi,

Request for comments ....

Proposal:

Give DW an easier(1) way to alter the xhtml rendering of line-breaks in ordinary text.

Background:

- DW treats line-breaks in ordinary text as white space and translates them into spaces. - Early Creole (0.3-0.6) specs called for line-breaks to be preserved in the rendered (x)html, ie, converted to <br> or <br />. The Current Creole (1.0) has returned to ignoring them "while wiki admins gain experience in blog-style line endings". By blog-style they mean preserving the line-breaks in the rendered (x)html. - The line break(*) plugin provides a mechanism for supporting line- break preservation. Its a very awkward plugin and has to do some quite complex intervention in DW parsing and rendering to accomplish the preservation. It is awkward and complex because DW provides no hooks into rendering of "cdata" data in the parser and because of the way DW implements section editing.

Is it required?
- Some users get confused by the way DW handles line-breaks. Conversely, users tend to view the way output appears on their browser as THE WAY output appears, when in reality it may look completely different on another browser/os/device.
- Some content benefits from user controlled line-breaks (e.g. poetry).

I have no way of determining the numbers or proportion of users/wiki that would benefit from this.


Potential Solutions:

(1) Add a config option to control the way line breaks are handled in xhtml handler. In addition add some control syntax to switch to the opposite mode for the current page (e.g. ~~LINEBREAK:IGNORE~~ or ~~LINEBREAK:PRESERVE~~).

(2) Add a hook into the xhtml renderer's "cdata" method to allow plugins to modify the data it processes.

(3) Add a hook into the xhtml renderer to allow the behaviour of "cdata" method to be modified.

(4) Add a config setting to select the xhtml renderer in much the same way as auth backends or templates are selected.


My Comments:

(1) is most likely the easiest to implement, but will clutter DW core with an option/behaviour that is nice but not strictly necessary.

(2) is also easy to implement (e.g. as an action plugin), but is likely to be very expensive in execution. The cdata handler is called often and the action plugin mechanism, while lightweight, isn't really suitable for operations that occur many times.

(3) is like (2), but is setup once at the start of rendering. Its not really how action plugins were designed to be used, but they could be bent to fit. e.g. the data for the plugin could be an array of filters to apply to cdata data. Action plugins responding to the event would modify the list. The array would consist of a single default filter - Doku_Renderer_xhtml::_xmlEntitities. The cdata method would be altered to pass the data to each filter in turn before adding the final result to the renderer string.

(4) The logic to select suitable renderers will be more complex than for either auth backends or templates as there is not one simple directory to place all the xhtml renderers. An extra method could be added to renderer plugins that are capable of replacing the xhtml renderer, "canReplaceRenderer($format)". This same mechanism is general enough to apply to other standard renderers (e.g. metadata & xhtmlsummary). To alter line-break behaviour the renderer would inherit from the xhtml renderer and redefine the cdata method.

-Chris

(*) I'm the author of the line-break plugin.




--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: