[pmwiki-users] Adding markup for Wikiwords for technical documentation
Joachim Durchholz
jo at durchholz.org
Thu Jun 9 13:19:00 CDT 2005
Jan Jacobs wrote:
> 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):
Then why not use '+'? It's just the same as {1,} :-)
> 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.
Like this:
(?<![a-z])[A-Z][A-Z0-9]+(?[a-z])
> 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,
(?<![a-zA-Z_])[a-z]
> followed by an unknown amount of a-zA-z_,
[a-zA-Z_]*
> but with the prerequisite that at least 1 uppercase character is
> present.
[A-Z][a-zA-Z_]*
No lookahead assertion needed, since the pattern will just eat up
everything as long as it matches, so the next character after the
pattern is already guaranteed to not be in [a-zA-Z_]. (That's different
from the first pattern, since we didn't want to match SD if it was in SDf.)
> 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')");
As above: replace {0,} with *. That's the shorthand (and more widely
known than the {n,m} notation).
> 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.
Regards,
Jo
More information about the pmwiki-users
mailing list