[pmwiki-users] div text pattern

John Rankin john.rankin at affinity.co.nz
Sun Nov 30 18:15:07 CST 2008


>Date: Sat, 29 Nov 2008 12:27:53 +0100
>From: noskule <noskule at gmx.net>
>Subject: [pmwiki-users] div text pattern
>
>hi list
>Is there a TextPattern variable where I could configure div markup like thre is 
>for conditions ($CondTextPattern).
>
>I would like to use names instead of numbers for divs.
>
>(:div_container ...:)
>....
>(:div ...:)
>....
>(:divend:)
>
>(:div_containerend:)
>
>
>thanks for any hints
>nos

I can think of 2 options that might work:

1. translate text suffixes into numbers

Something like this:

Markup('customdiv', '<table',
    '/^(\\(:div)_([^\s:]+)((?:end)?(?:\\s.*?)?:\\))/e',
    "'$1'.MapDivSuffix('$2').PSS('$3')");

function MapDivSuffix($txt) {
  static $DivSuffix, $DivIndex;
  if (isset(@$DivSuffix[$txt]))
      return $DivSuffix[$txt];
  $DivIndex++;
  $DivSuffix[$txt] = $DivIndex;
  return $DivSuffix[$txt];
}


2. redefine the table markup rule

Something like this:

Markup('table', '<block',
    '/^\\(:(table|cell|cellnr|tableend|div\\d*(?:_.*?)?(?:end)?)(\\s.*?)?:\\)/ie',
    "Cells('$1', PSS('$2'))");


Hope this helps
JR
-- 
John Rankin
Affinity Limited
T 64 4 495 3737
F 64 4 473 7991
021 RANKIN
john.rankin at affinity.co.nz
www.affinity.co.nz





More information about the pmwiki-users mailing list