====== xbr plugin ======
---- plugin ----
description: replacement renderer, preserves line breaks present in raw wiki data
author : Christopher Smith
email : chris@jalakai.co.uk
type : render
lastupdate : 2008-11-11
compatible : 2008-05-05
depends :
conflicts :
similar : linebreak
tags : typography, !experimental
downloadurl: http://dokuwiki.jalakai.co.uk/plugin-xbr.zip
----
===== Description =====
[[:experimental]]
This plugin enables the preservation of line breaks from the raw wiki text through to the html output. It is a replacement for the standard DokuWiki XHTML renderer, as such to use it you must set the [[config:renderer_xhtml]] setting to the plugin's name, **''%%'xbr'%%''**. For simplicity's sake the plugin uses all of the standard renderers routines with the exception of plain character output, where it uses its own routine to replace new lines with the HTML element, **''
''**.
Note, the plugin does not preserve multiple consecutive line breaks, but it will preserve single line breaks.
Also see the [[plugin:linebreak]] plugin.
===== Download and Installation =====
* [[http://dokuwiki.jalakai.co.uk/plugin-xbr.zip|zip format]]
* [[http://dokuwiki.jalakai.co.uk/plugin-xbr.tar.gz|tar.gz format]]
* [[http://wiki.jalakai.co.uk/repo/dokuwiki/plugins/xbr/|darcs repository]]
Plugin source code is also available below, refer to [[:plugins]] on how to install plugins manually. After installation set the [[config:renderer_xhtml]] configuration setting (via your wiki's admin panel) to **''%%'xbr'%%''**.
===== Revision History =====
* 2008-11-11 --- installable packages and darcs versions prepared. No changes.
* 2008-08-13 --- released
===== Source =====
file: ''lib/plugins/xbr/renderer.php''
*/
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_INC . 'inc/parser/xhtml.php';
/**
* The Renderer
*/
class renderer_plugin_xbr extends Doku_Renderer_xhtml {
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Christopher Smith',
'email' => 'chris@jalakai.co.uk',
'date' => '2008-11-11',
'name' => 'XBR',
'desc' => 'XHTML renderer with line break preservation.',
'url' => 'http://www.dokuwiki.org/plugin:xbr',
);
}
function canRender($format) {
return ($format=='xhtml');
}
function reset() {
$this->doc = '';
$this->footnotes = array();
$this->lastsec = 0;
$this->store = '';
$this->_counter = array();
}
function cdata($text) {
$this->doc .= str_replace("\n",'
',$this->_xmlEntities($text));
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
===== Bugs =====
===== To Do (feature requests) =====
===== Discussion / Requests for help =====
==== Unintended br ====
Parsing of the linebreaks after headers, tables, lists, or other block elements doesn't seem to be well normalized. [[devel:rewriteblocks:demo|Here is a sample test page]].
If xbr is installed and turned on, there would be an extra pre-br at the "test" after "Header spacing 2" and "Header spacing 4", for example.
This problem could be solved by adding a trim - replace line 45:
$this->doc .= str_replace("\n",'
',$this->_xmlEntities($text));
With this:
$this->doc .= str_replace("\n",'
',trim($this->_xmlEntities($text),"\n"));
So far I havn't seen adverse effects after making this change. --- [[user>danny0838]] //2010/12/31 15:12//
> I recently found that this fix may lead to linebreak missing if previous mark goes to the end. For example:
>
>
Line 1 **Bold Text**
Line 2
> The linebreak between line 1 and line 2 will miss.
> It seems that this problem cannot be fixed without [[devel:rewriteblocks|fixing the core code]]. --- [[user>danny0838]] //2011/01/23 08:16//
==== well-visualized html output ====
Adds a linebreak after
element so the HTML source is more readible:
$this->doc .= str_replace("\n",'
',$this->_xmlEntities($text));
$this->doc .= str_replace("\n","
\n",$this->_xmlEntities($text));
--- [[user>danny0838]] //2011/01/23 08:49//