[pmwiki-users] Defining a Variable in a Wiki Page (Continue)

Américo Albuquerque aalbuquerque at lanowar.sytes.net
Fri Apr 21 16:28:06 CDT 2006


Hello

I've been tweaking with defining a variable in a wiki page. I come up 
with an algorithm that, theoretical, should work. The problem was the I 
needed to use different Markups but that have the same regexp. PmWiki 
doesn't allow that. The last Markup simply overwrites the previous. So 
I've made some changes in BuildMarkupRules and in MarkupToHTML to allow 
this. With this changes the code work just fine.

In BuildMarkupRules I changed

$MarkupRules[str_replace('\\L',$LinkPattern,$m['pat']] = $m['rep'];

to

$MarkupRules[] = array('pat'=>str_replace('\\L',$LinkPattern,$m['pat']), 
'rep'=>$m['rep']);

and in MarkupToHTML I changed

     foreach($markrules as $p=>$r) {

to

     foreach($markrules as $preg) {
       $p = $preg['pat'];
       $r = $preg['rep'];

This allow 2 markup with different names have the same regexp
Is there a chance in this being adopted by the Core?
You could define a variable like $AllowDuplicateRegexRules and use:

if($AllowDuplicateRegexRules) $MarkupRules[] = 
array('pat'=>str_replace('\\L',$LinkPattern,$m['pat']), 'rep'=>$m['rep']);
else {
   $pat = str_replace('\\L',$LinkPattern,$m['pat']);
   $MarkupRules[$pat] = array('pat'=>$pat, 'rep'=>$m['rep']);
}

This way both implementations could be used

Américo Albuquerque










More information about the pmwiki-users mailing list