[dokuwiki] Re: Help wanted with accepts() in very simple plugin

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 21 Jun 2012 15:17:04 +0100

On 21 Jun 2012, at 13:47, Chris Green wrote:

> I have an almost trivial plugin that simply wraps a <DIV class=xxx> ...
> </DIV> round a chunk of text to allow me to apply a custom style to
> the text.
> 
> The code of the plugin is attached (there's only 134 lines of it).  It's
> working exactly as expected *except* that the accepts() call isn't
> turning off preformatted mode.
> 
> This may well be because I have done something wrong - should I be doing
> the return parent::accepts($mode); ?
> 
> Alternatively it may simply be that calling accepts() in this way doesn't
> disable preformatting of text because I'm calling $renderer->render() to
> parse the text 'inside' my plugin.  Is there a more elegant way to have
> a plugin 'wrap' some text with start and end patterns but still parse
> the intervening text?
> 
> 
> More fundamentally am I going about this the right way, all I want to do
> is to have a plugin handle something like:-
> 
> /l
> 1234-56-78      Some text
>                More text with a [[link]] maybe
>                Even more text ++ More | Loads more text folded with the 
> folded plugin ++
> 9101-12-13      The next bit
> /
> 
> I want to prevent the leading spaces on some lines from switching into
> preformatted mode so the text is parsed normally and the link and folded
> sections work as expected.
> 
> -- 
> Chris Green
> <syntax.php>

As I said before you're fighting dokuwiki trying to make it do something its 
not been designed to do.

If you "accept" other syntax modes and but you don't want to accept them all 
(e.g. not accepting pre-formatted) then you should handle "accepts()" yourself 
to ensure it does what you want.  However, you can't prevent any mode you do 
accept from accepting what it chooses.

The different groups of syntax modes are all detailed in the documentation.  
You would be safe to include the formatting modes (e.g bold) and links.  I 
doubt you could accept the folded plugin as it can accept everything.

One solution might be to register a syntax plugin for two spaces at the start 
of a line and prioritize it below the dokuwiki syntax.  You need to be careful 
not to clash with lists, which also start lines with two spaces.

Another is to write your own render plugin to replace the default renderer.  
Then you should be able to do what you like.

- Chris


--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: