[dokuwiki] Re: need help with a syntax plugin
- From: Chris Smith <chris@xxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Thu, 29 Dec 2005 10:25:56 +0000
Flavio Curti wrote:
Hello
I try to create a plugin for dokuwiki that describes the assignment of
rack-space to customers. My idea was to make it look like this:
<rack name="A5">
<desc>this is rack a5, needs the keys 220N</desc>
<he height="12" [from="2"]>
[[customer xyz]] uses this for whatever
</he>
<he height="12" [from="14"]>
[[customer abc]] uses this for whatever
</he>
</rack>
Now I was able to create a plugin that works on the <rack></rack> tags.
However I'm now struggeling on parsing the other tags as easy as
possible. I was thinking of using addPattern in the connectTo function,
but I'm not sure how to describe the patterns.
If anyone could shed some light on this, I'd greatly appreciate it.
Thank you and kind regards
Flavio Curti
--
http://no-way.org/~fcu/
Use addPattern in postConnect(). Its only called once where as
connectTo is called many times. Its actually called by all the other
syntax modes to tell them what other syntaxes to allow. Since your
extra patterns will only apply to your plugin and its syntax mode it is
sensible to do the pattern adding once only in postConnect().
Syntax plugins aren't setup to easily handle entering and exiting other
syntax modes from within your syntax mode. You can either take care of
that within your handle function or add other plugin components which
will only "connectTo" your plugin.
======================================================================
method 1 : addPattern
$this->Lexer->addPattern('<he .*?>', 'plugin_rack');
$this->Lexer->addPattern('</he>', 'plugin_rack');
$this->Lexer->addPattern('[[customer .*?]],'plugin_rack');
======================================================================
method 2: if you don't allow any dokuwiki formatting within your
<rack>...</rack> tags use this as its the simplest
$this->Lexer->addSpecialPattern('<rack.*?</rack>', 'plugin_rack');
you need to then pull apart the intervening data and process it yourself
======================================================================
method 3: most complex, use component plugins
plugin_rack_rack -
in connectTo ...
$this->Lexer->addEntryPattern('<rack.*?>(?=.*</rack>)',
'plugin_rack_rack');
in postConnect ...
$this->Lexer->addExitPattern('</rack>', 'plugin_rack_rack');
plugin_rack_desc -
in connectTo ...
if ($mode == 'plugin_rack_rack') {
$this->Lexer->addEntryPattern('<desc>(?=.*</desc>)',
'plugin_rack_desc');
}
in postConnect ...
$this->Lexer->addExitPattern('</desc>', 'plugin_rack_desc');
plugin_rack_he -
in connectTo ...
if ($mode == 'plugin_rack_rack') {
$this->Lexer->addEntryPattern('<he.*?>(?=</he>)', 'plugin_rack_he');
}
in postConnect ...
$this->Lexer->addExitPattern('</he>', 'plugin_rack_he');
plugin_rack_customer -
in connectTo
if ($mode == 'plugin_rack_he') {
$this->Lexer->addSpecialPattern('[[customer
.*?]]','plugin_rack_customer');
}
======================================================================
As I said above, if you aren't intending Dokuwiki markup to occur within
<rack> ... </rack> then go with the simple option - method 1.
I hope that all made sense :)
Cheers,
Chris
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
- Follow-Ups:
- [dokuwiki] Re: need help with a syntax plugin
- From: Chris Smith
- References:
- [dokuwiki] need help with a syntax plugin
- From: Flavio Curti
Other related posts:
- » [dokuwiki] need help with a syntax plugin
- » [dokuwiki] Re: need help with a syntax plugin
- » [dokuwiki] Re: need help with a syntax plugin
Hello
I try to create a plugin for dokuwiki that describes the assignment of rack-space to customers. My idea was to make it look like this:
<rack name="A5"> <desc>this is rack a5, needs the keys 220N</desc> <he height="12" [from="2"]> [[customer xyz]] uses this for whatever </he> <he height="12" [from="14"]> [[customer abc]] uses this for whatever </he> </rack>
Now I was able to create a plugin that works on the <rack></rack> tags. However I'm now struggeling on parsing the other tags as easy as possible. I was thinking of using addPattern in the connectTo function, but I'm not sure how to describe the patterns.
If anyone could shed some light on this, I'd greatly appreciate it.
Thank you and kind regards
Flavio Curti
--
http://no-way.org/~fcu/
-- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist
- [dokuwiki] Re: need help with a syntax plugin
- From: Chris Smith
- [dokuwiki] need help with a syntax plugin
- From: Flavio Curti