[pmwiki-users] (:directive:) in (:mytext: this is a hidden PTV:)

Dominique Faure dominique.faure at gmail.com
Tue Apr 20 07:10:03 CDT 2010


On Tue, Apr 20, 2010 at 12:26, Hans <design5 at softflow.co.uk> wrote:
> Tuesday, April 20, 2010, 11:07:32 AM, Dominique Faure wrote:
>
>> oops, the generic version should be more elaborated:
>
>> $MarkupExpr['directive'] = 'preg_replace("/\\n$/", "",
>>                                MarkupToHTML($pagename,
>>                                             "<:block>(:" .
>> trim(preg_replace($rpat, $rrep, $params)) . ":)",
>>                                             array("escape" => 0)))',
>
>> should do the trick
>
> this did not work, even with ';' at end instead of ','
> but your previous suggeastion works with thumb and thumblist.

Here's my full bench:

=====8<- - - - - (Test.MarkupExpr wiki page) - - - - -
:PTV1: ptv1 (:mymarkup aaaa bbbb:) ptv1
:PTV2: ptv2 {(directive mymarkup cccc dddd)} ptv2
(:PTV3: ptv3 {(directive mymarkup eeee ffff)} ptv3 :)

* {$:PTV1}
* {$:PTV2}
* {$:PTV3}

=====8<- - - - - (Test.MarkupExpr.php) - - - - -
Markup('mymarkup', 'directives', "/\\(:mymarkup\\s+(.*?):\\)/sei",
  "MyMarkup(\$pagename, PSS('$1'))");

function MyMarkup($pagename, $args) {
  return "This is my markup...\"$args\"";
}

if(true) {
  $MarkupExpr['directive'] =
    '"(:" . trim(preg_replace($rpat, $rrep, $params)) . ":)"';
} else {
  $MarkupExpr['directive'] =
    'preg_replace("/\\n$/", "", MarkupToHTML($pagename,
      "<:block>(:" . trim(preg_replace($rpat, $rrep, $params)) . ":)",
      array("escape" => 0)))';
}
- - - - - - - - - - - - - - -

While having the 1st solution active, the page is rendered as below,
where you may see an evaluation artefact ("ptv3 :)") while rendering
PTV2 definition:

=====8<- - - - -
PTV1
  ptv1 This is my markup..."aaaa bbbb" ptv1
PTV2
  ptv2 This is my markup..."cccc dddd" ptv2 ptv3 :)

* ptv1 This is my markup..."aaaa bbbb" ptv1
* ptv2 This is my markup..."cccc dddd" ptv2
* ptv3 This is my markup..."eeee ffff" ptv3

=====8<- - - - -

Reversing the test to activate the other definition, let the markup
render without the offending "ptv3 :)"

> Is
> $MarkupExpr['directive'] = '"(:" . trim(preg_replace($rpat, $rrep, $params)) . ":)"';
> restricted to directives without line breaks?

The MarkupExpr markup definition, ie. the {(...)} general processing
isn't designed to handle multiple lines.

-- 
Dominique



More information about the pmwiki-users mailing list