[dokuwiki] Re: plugin: recursive syntax substitution
- From: Christopher Smith <chris@xxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 18 Mar 2009 14:46:24 +0000
On 18 Mar 2009, at 11:57, Andreas Wagner wrote:
Hi all,
in further developing a plugin [1] for interaction with wikindx [2],
I am trying to draw more resources from the remote database than
just resource titles. Quotes is what I'm at - and in wikindx, quotes
(and probably other entries (notes, musings, ...) can contain
references to other resources. I can successfully s/wikindx-syntax/
dw-my_plugin-syntax in the generated string, but then the plugin
would have to start over and also resolve the dw-my_plugin-syntax
term. I have tried mode type 'substitution' and 'container' for the
plugin with both of them also in the AllowedTypes array. But I think
the recursion just isn't triggered.
Syntax plugins don't have a mechanism for feeding back changes to the
parser for it to process those changes. You can instantiate another
parser, however that is an expensive operation. If you expect to need
to process several "snippets" in the course of a wiki page, your
plugin could instantiate and save a parser and then resuse that parser
for subsequent snippets.
See inc/parserutils.php in particular p_get_instructions() for details
on parsing wiki text into instructions.
To hand the converted instruction list back to your original parser
you can look at the call rewriters in inc/parser/handler.php or simply
iterate over the list and call _addCall() for each. You will probably
have to make some adjustments to the "pos" field. Alternatively, you
could piggy back on the nest call rewriter.
There maybe hidden gotchas in this method. E.g. the instructions
created for a wiki page are used by at least two renderers, metadata
and xhtml. The xhtml renderer could be a plugin.
You may also want to look into using an action plugin to handle
PARSER_WIKITEXT_PREPROCESS. It could look for your syntax and do the
substitutions of the converted syntax before the wikitext is handed to
the parser removing the need for all the above fancy shenanigans in a
syntax plugin - a syntax plugin wouldn't be necessary at all.
- Chris
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
Other related posts: