[pmwiki-users] Adding markup for Wikiwords for technical documentation

Patrick R. Michaud pmichaud at pobox.com
Thu Jun 9 13:57:37 CDT 2005


On Thu, Jun 09, 2005 at 08:19:00PM +0200, Joachim Durchholz wrote:
> >Markup('myCustomWikiWord2','>myCustomWikiWord1',"/[A-Z][A-Z0-9]{1,}/e",
> >"Keep(WikiLink(\$pagename,'$0'),'L')");
> 
> OK, so you don't want to wikify a single upper-case letter.
> 
> Um... maybe you should add a lookbehind and a lookahead assertion to 
> prevent lowercase letters before and after the string. I.e. with the 
> above, you'll have SD wikified in aSDf.

First, to change (or add) WikiWords doesn't always require a custom
markup, one can always simply change the definition of $WikiWordPattern.

Also, lookahead/lookbehind isn't needed here--just use \b to force the
pattern onto a word boundary.  ($WikiWordPattern has the \b built-in.)

> >2) This does not do anything yet.  But maybe I wasn't so clear in the
> >first explanation, although you guess correctly about the programming
> >language stuff.  I want to WikiWord any word that starts with a
> >lowercase character a-z, followed by an unknown amount of a-zA-z_,
> >but with the prerequisite that at least 1 uppercase character is
> >present.

Okay, let's put everything together.  I'm assuming you want existing
WikiWords to work also.  And let's not forget about \w, which
is a letter, digit, or underscore -- much easier to write.

So, we want any sequence that begins with an uppercase letter and
has at least one more uppercase letter or digit, or any sequence
starting with a lowercase letter that is followed by at least one
uppercase letter:

    $WikiWordPattern = 
      "[[:upper:]]\\w*[[:upper:]0-9]\\w*|[[:lower:]]\\w*[[:upper:]]\\w*";

That seems to do it.

> >Now, as a new question: is there a way to let pmWiki preserve
> >underscores in Wikiwords?  When I make a wikilink with the above
> >statements, for example sp_Test, it makes a wikiword like spTest,
> >while I rather keep sp_Test, even as filename.  Is this possible?
> 
> I pass this question on to the others. Not my area of expertise - I've 
> never had reason to modify page name mangling behavior.

By default PmWiki converts anything that isn't a hyphen or an alphanumeric
character to a space, as controlled by the $PageNameChars variable.
You can allow underscores in page names by setting:

    $PageNameChars = "-_[:alnum:]";

Pm



More information about the pmwiki-users mailing list