[pmwiki-devel] disabling and modifying markup for specific recipe output

Hans design5 at softflow.co.uk
Tue Aug 25 06:12:41 CDT 2009


Tuesday, August 25, 2009, 1:26:32 AM, Patrick wrote:

> I think we should move the call to BuildMarkupRules to just before
> the foreach() statement on line 1506.  Then any markup rule can
> make a call to DisableMarkup() or add a new markup rule and restart
> text processing by calling PRR().

I tested this, without success.

I used the following test markup definitions, to make testing simpler:

Markup("testmx","directives","/\\(:testmx\\s+(.*?):\\)/ei",
     "TestMX(\$pagename, PSS('$1'))");

$MarkupExpr['testmx'] = 'TestMX($pagename, @$args)';

function TestMX($pagename, $args) {
        if (!is_array($args)) $args = explode(" ", $args);
        
        DisableMarkup("'''");
        PRR();

        $text = implode(" ",$args);
        echo $text;
        
        $out = MarkupToHTML($pagename, $text);
        echo $out;

        return Keep($out);
}

I added the echos for easier debug.
To test I used in a page:

normal text '''bold text''' ''italic text'' '''''bold italic text'''''
----
{(testmx "normal text '''bold text''' ''italic text'' '''''bold italic text'''''")}
----
(:testmx normal text '''bold text''' ''italic text'' '''''bold italic text''''':)


I was not able to disable any markup from within the function, nor
modify it. Disabling from within config.php works fine,
but the point is to localise the change to the output from th emarkup
expression or directive.

> This still doesn't help if the rule to be disabled occurs earlier in
> the sequence than the rule that is doing the disabling, but it is more
> in line with what I expect should happen.

the inline rules come later than the markup expressions and
directives, so I expected it to work, but it does not.

> Would it be sufficient
> for your needs, or do we really need something else here also?
> Perhaps you could explain what you're wanting to disable in a little
> more detail?

I am revising the TextExtract recipe. TextExtract can do a "context
sensitive" search by extracting whole text lines which matches the
search terms, and presenting it line by line. Doing this it is
desirable to cut out certain markup, neutralise or modify it, in
order to get readable results.

I can do this by adding the right kind of preg_replace expressions
when processing the text, but I thought that I could perhaps utilise
the markup engine and run it in a customised way just to generate the
desired output. If i can't I seem to end up building something like a
mini markup engine within my function.

> I think we should move the call to BuildMarkupRules to just before
> the foreach() statement on line 1506.

Does this not have the effect that  BuildMarkupRules() is called for
every text line processed? Maybe that is not necessary if
MarkupToHTML() can be called with an option to modify the ruleset for
the duration of that call? But I understand too little about it.


Hans




More information about the pmwiki-devel mailing list