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

Jan Jacobs Jacobsjan at spector.be
Thu Jun 9 12:26:11 CDT 2005


Joachim,

thanks for the help already

1) I used the following regex to achieve the required result (note that I'm still new, and that the {1,} syntax is a little less confusing when looking back at the regex after 10 minutes):

Markup('myCustomWikiWord2','>myCustomWikiWord1',"/[A-Z][A-Z0-9]{1,}/e", "Keep(WikiLink(\$pagename,'$0'),'L')");

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.  What I came up with is the following, but I guess it needs a bit more testing before I'm sure its the right syntax.

Markup('myCustomWikiWord1','>wikilink',"/[a-z][a-z_]{0,}[A-Z][a-zA-Z_]{0,}/e", "Keep(WikiLink(\$pagename,'$0'),'L')");


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?

Jan

-----Original Message-----
From: Joachim Durchholz [mailto:jo at durchholz.org]
Sent: donderdag 9 juni 2005 18:42
To: Jan Jacobs
Cc: pmwiki-users at pmichaud.com
Subject: Re: [pmwiki-users] Adding markup for Wikiwords for technical
documentation


Jan Jacobs wrote:
> 1) a word consisting entirely out of uppercase characters (with or 
> without numerics).

[A-Z0-9]+

i.e. something that consists of a sequence of uppercase letters and digits.

You probably don't want something that consists just of digits. That 
would be something that has one uppercase letter, and (possibly empty) 
sequences of letters/digits before and after:
   [A-Z0-9]*[A-Z][A-Z0-9]*

If the first character cannot be a digit, you get
   [A-Z][A-Z0-9]*

> 2) a sequence of characters, not separated by a whitespace character, 
> not starting with an uppercase character, but containing 1 or more 
> uppercase characters.  The entire sequence of characters should be 
> turned into a wikiword.

Um... you probably don't want to wikify character sequences that contain 
punctuation. Otherwise, in the previous sequence, you'd end up with 
"don't" wikified, and "m..." (that's the first word, without the capital 
U - a "character sequence" may be preceded with an uppercase character).

>           o tTable
>           o tTable_With_Underscores
>           o un_Filehandling

Seems like you're after sequences of letters and underscores (and, since 
this looks like programming language variables, digits as well). To 
avoid wikifying "lah" in "Blah", the pattern must not be applied 
immediately after an uppercase letter, so we need a "lookbehind 
assertion" (that's a condition that says "apply this pattern only after 
such-and-so"). The lookbehind should say "after anything but an 
uppercase letter", which is [^A-Z]. Putting this together we have
   (?<=[^A-Z])[a-zA-Z0-9_]+
IOW this will match all strings consisting of letters, digits, and 
underscores that follow anything but an uppercase letter.

Hope this gets you started.

Regards,
Jo





More information about the pmwiki-users mailing list