[Pmwiki-users] PmWiki 2 custom markup, draft 1
Sun Sep 5 19:00:43 CDT 2004
On Thursday, 2 September 2004 1:47 AM, Patrick R. Michaud <pmichaud at pobox.com> wrote:
>This message briefly describes how one goes about adding custom markup
>in PmWiki 2.0. I'm also adding this as the PmWiki.CustomMarkup page
>on pmwiki.org, so changes can go there.
>PmWiki's markup translation engine is handled by a set of rules; each
>rule searches for a specific pattern in the markup text and replaces it
>with some replacement text. Internally, this is accomplished by using PHP's
>Rules are added to the translation engine via PmWiki's Markup() function,
>which looks like
>where $name is a unique name (a string) given to the rule,
> $when says when the rule should be applied relative to other rules,
> $pattern is the pattern to be searched for in the markup text, and
> $replace is what the pattern should be replaced with.
This looks superb!
Let me test a scenario, which appears not easy in 1 (?) but entirely
possible in 2.
An author wants to insert a
directive to break up a long page into readable chunks.
In printable view, the reader sees the whole page and [:newpage:]
directives are simply ignored.
In browse view, pmwiki initially displays the text up to the first
[:newpage:] directive, plus a
Page 1 2 3 ...
line. 1 is just 1; 2 is a link to page 2 (contents between the first
and second [:newpage:] directives), and so on. Clicking on 2 displays
page 2, with a link back to page 1 and on to pages 3, 4 etc. It would
generate a list of page number links based on the number of [:newpage:]
So with PmWiki 2, it's something like:
Markup("newpage",">include","/\\[:newpage:\\]/e", then I get lost...
I'd want to execute
if (strstr($Text,'[:newpage:]')) $Text = NewpageDirectives($Text);
after include processing but before other directive processing.
The NewpageDirectives function seems pretty trivial.
So how do I invoke this?
More information about the pmwiki-users