[pmwiki-devel] Markup routine for style questions

Peter Bowers pbowers at pobox.com
Fri Oct 26 13:34:34 CDT 2012


On Fri, Oct 26, 2012 at 6:19 PM, W Randolph Franklin
<pmwiki at wrfranklin.org> wrote:
>
...
> Markup('^>>', '<table',
>   '/^>>(.+?)<<(.*)$/',
>   '(:div:)%div $1 apply=div%$2 ');
> Markup('^>><<', '<^>>',
>   '/^>><</',
>   '(:divend:)');
>
> My questions:
>
> 1. Why is > used instead of > in the search pattern?   Since the page
> being edited contains >, this should always fail.

See htmlentities or htmlspecialchars.  Typically in HTML putting < or
> signs will be interpreted as commands to HTML and so to avoid that
you use these special entities if you want to actually see a LT or GT
sign.

> 2. Is there a reason that the pattern name is ^>> ?  Does the leading ^
> do anything in the pattern name?

The name of the rule is arbitrary -- it has no functional value other
than to identify the rule.  Since this rule fires with lines that
START with >> the name of the rule includes the ^ anchor character
just so someone who knows regular expressions will know what type of
search will occur.  But you could name it foo or sally or
rumpelstiltskin and it would not change the behavior of the rule --
it's just the name of the rule.

> 3. In  '/^>>(.+?)<<(.*)$/',   what is the final (.*)$ for?
>  The documentation does not mention trailing text after the <<.

Looks like it just strips off any characters after the closing << and
then puts them back on again.  So practically it has no effect.
Probably there was some special behavior that broke if it wasn't
handled like this, but since it didn't affect the functionality from a
user's perspective it's not mentioned in the documentation.  You would
probably have to do some extensive testing to figure out what breaks
if you don't do that (or else hope that PM or Petko has a long memory
and can help you...)

> 4. In  '(:div:)%div $1 apply=div%$2 '),   what do the percents do?  This
> looks like a nested div, why?

Looks like some style is being applied, but someone else more familiar
with the % styles can answer that one.

> 5. Finally how do I set styles inside list items?   >><< and (:div:)
> terminate the list because they work only in column 1.   Percents appear
> to have an implementation error, where using apply causes the style to
> be ignored.   I need to use apply=p to avoid other formatting problems.

I did this:

===(snip)===
!!list
*item 1
*%red%red item%%
*item 3
===(snip)===

and it worked fine...  Maybe I didn't understand what the issue was?

-Peter



More information about the pmwiki-devel mailing list