[dokuwiki] Lexer and Regular Expressions

  • From: Chris Tregenza <Chris@xxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 04 Jan 2012 12:53:19 +0000

Hi,

I'm adding a syntax pluging to handle some special mark up that comes in two forms -

<card >Some stuff</card>

<card  some="stuff"  />

These need different handling so I'm adding patterns the Lexer as -

    function connectTo($mode) {
$this->Lexer->addEntryPattern('<card.*?[^\/]>', $mode, 'plugin_6d6v2_card');
        $this->Lexer->addExitPattern('<\/card>', 'plugin_6d6v2_card');

$this->Lexer->addSpecialPattern('<card.*?\/>', $mode, 'plugin_6d6v2_card');

    }

But this throws up an error -

PHP Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier ']' in .../inc/parser/lexer.php on line 115

and the plugin's handle function is not not triggered.

The general PHP advice for the error is to use delimiters around the expression but this is not allowed in the Lexer (according to the wiki).

What regular expression should I be using so that '<card >' will be flagged as an entry pattern but not '<card />'?

Thanks

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

Other related posts: