[dokuwiki] Re: How to parse/render a string through the main DokuWiki parser/renderer?

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 9 Feb 2009 09:35:09 +0900


On 9 Feb 2009, at 00:41, Frank Thommen wrote:

Hi Christopher,

Thanks.

<snip>

$success is written out literally by the bureaucracy plugin. "====Hello====" gives "====Hello====" instead of a headline level 3. I want (i.e. need for my purposes), that $success is parsed and rendered so that I can put DokuWiki syntax in this variable.

Can you give me a hint what I have to do to achieve this or where in the documentation I should have a look?

Take a look at the render() method in the plugin base clase (base for other plugin types not for syntax plugins) inc/plugin.php.

How should that be used?

Read the source. Follow through how dokuwiki is actually calling the function. Use the "xref" link in the sitebar on www.dokuwiki.org. As I recall, p_render doesn't take a string of raw wiki text as a parameter, but a list of "instructions" that were themselves made from a string of raw wiki text. There are pages on www.dokuwiki.org that explain how the parser works (and the effect of caching).



There are some gotchas that may or may not apply to your situation:
- Calling the parser instantiates a new parser which is an expensive operation.

Hmm. But do I have a choice? This will not happen very often, so probably I could live with it.


- DokuWiki caches the rendered wiki page so it doesn't need to render it each time.

This will become a dynamic page that changes at each invocation. So caching will not help ;-)

I'm just pointing these out to you. With regard to caching, DokuWiki does it automatically. If you don't want it to happen, you have to actively turn it off in your plugin.

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

Other related posts: