diff options
author | Andreas Gohr <andi@splitbrain.org> | 2007-03-03 22:41:02 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2007-03-03 22:41:02 +0100 |
commit | 5f70445d51e06ae1a3d1bf820f97238942985fde (patch) | |
tree | ec4f24b5a0447e6c855a059c247cd32d43e8a4db /inc/parser | |
parent | 47b2d319dce63bf054ff2428b9efedccc6b695f7 (diff) | |
download | rpg-5f70445d51e06ae1a3d1bf820f97238942985fde.tar.gz rpg-5f70445d51e06ae1a3d1bf820f97238942985fde.tar.bz2 |
added getFormat() function to renderer
Each renderer has to supply a getFormat() function returning the format it
produces. Usually this is the same as the classname of the renderer (or Plugin)
says but it does not need to be necessarily.
Fixes a problem with the wrong format being reported to plugins when a
render plugin was used.
darcs-hash:20070303214102-7ad00-3f87d8a10e94f4c6c30bacc8f43486b94ecdb146.gz
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/metadata.php | 4 | ||||
-rw-r--r-- | inc/parser/renderer.php | 14 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 5 |
3 files changed, 20 insertions, 3 deletions
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 04a9ed8b1..85e6eefed 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -32,6 +32,10 @@ class Doku_Renderer_metadata extends Doku_Renderer { var $capture = true; var $store = ''; + function getFormat(){ + return 'metadata'; + } + function document_start(){ // reset metadata to persistent values $this->meta = $this->persistent; diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 0e6fa2d85..1b6340445 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -37,13 +37,21 @@ class Doku_Renderer extends DokuWiki_Plugin { $this->info['toc'] = false; } + /** + * Returns the format produced by this renderer. + * + * Has to be overidden by decendend classes + */ + function getFormat(){ + trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING); + } + + //handle plugin rendering function plugin($name,$data){ $plugin =& plugin_load('syntax',$name); if($plugin != null){ - // determine mode from renderer class name - format = "Doku_Renderer_<mode>" - $mode = substr(get_class($this), 14); - $plugin->render($mode,$this,$data); + $plugin->render($this->getFormat(),$this,$data); } } diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index ea5b72495..e397f5bd7 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -36,6 +36,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { var $lastsec = 0; var $store = ''; + function getFormat(){ + return 'xhtml'; + } + + function document_start() { //reset some internals $this->toc = array(); |