[pmwiki-devel] Markup routine for style questions
Patrick R. Michaud
pmichaud at pobox.com
Fri Oct 26 15:59:25 CDT 2012
On Fri, Oct 26, 2012 at 12:19:06PM -0400, W Randolph Franklin 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.
One of the first markup rules that PmWiki performs is to convert all
<'s and >'s to html entities to minimize injection attacks.
> 2. Is there a reason that the pattern name is ^>> ? Does the leading ^
> do anything in the pattern name?
Pattern names are just identifiers, so it doesn't do anything.
But someone reading the rule or seeing the identifier in a list
would be informed that it's a markup that only applies at the beginning
of lines.
> 3. In '/^>>(.+?)<<(.*)$/', what is the final (.*)$ for?
> The documentation does not mention trailing text after the <<.
I'm not sure why there's a trailing (.*)$ there. There must've been
something that failed when it wasn't there, though.
> 4. In '(:div:)%div $1 apply=div%$2 '), what do the percents do? This
> looks like a nested div, why?
This rule is taking markup of the form
>>red something<< text
and converting it to markup of
(:div:)%div red something apply=div% text
This then gets processed by the standard (:div:) and WikiStyle
markup rules. The percents are just the standard WikiStyle markup,
with the first 'div' causing standard div styles to be applied,
and the 'apply=div' being thrown in to force application of the style
to the entire <div> element that is ultimately generated.
> 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.
You might want %item%, as in:
* First item
* %item red% This item is red
* This item is normal
* %item blue% This item is blue
> --------------------
>
> In a list item, percents work, boxing each line. > < and div do not, if
> indented, or terminate the list, if not indented.
Technically, percent WikiStyles don't box an entire line -- they
box content until either the end of the line or the next WikiStyle.
> # In a list item, using any 'apply' inside percents causes the style to
> be ignored.
>
> %blue% blue
>
> %red apply=p ignored% red apply=p ignored
>
> %green% green
For a variety of reasons, PmWiki doesn't wrap the content of list items
as <p> paragraph elements, even when surrounded by blank lines. Thus the
'apply=p' has no effect inside of a list item because there's no
<p>...</p> available for it to apply the style to.
(One reason PmWiki doesn't put list item contents into <p>...</p> tags
is because <p> paragraphs in HTML 4 aren't allowed to have nested block
elements, such as nested lists. I decided nested lists were more
important and went that direction.)
What sort of "other formatting problems" are you needing to
avoid by using 'apply=p'?
Pm
More information about the pmwiki-devel
mailing list