[Pmwiki-users] Wikify(anythingi)
Patrick R. Michaud
pmichaud
Thu May 20 07:41:41 CDT 2004
The author code does it. Essentially you remove any characters
that don't fit in a page title and then freelink the rest using the
FreeLink function. So:
$str = preg_replace('/[^-\\w ]/','',$str);
$f = FreeLink("{{$str}}");
$str = $f['name'];
The FreeLink() function processes free link text and returns an array:
name => the title of the page corresponding tothe link
text => the display text for the link
group => the group specified in the freelink, if any
sep => the character separating the group from the name (i.e., '.' or '/')
Pm
On Thu, May 20, 2004 at 12:54:41PM -0700, Steven Leite wrote:
> Hello (anyone with RegExp knowledge),
>
> Is there a simple way to convert any string in to a valid WikiWord (or
> valid {{Free Link}} word) suitable for using as a $Title on a WikiPage?
>
> Here's what I have so far:
>
> function Wikify($str)
> {
> $str =
> $str = // a bunch of ereg_replace( ) statements to
> $str = // strip out any unwated characters, or
> possibly
> $str = // make substitutions.
> $str =
> return $str; // Returns the word, Wikified, suitable to be
> used in a $Title
> }
>
> In my case, $str would be a filename. IT would be nice if we could
> somehow utilize the existing $Page / $Group / $WikiWord / $FreeLink
> (Patterns). That way if those patterns every change, this function
> would still function. =)
>
> If you can spare a moment.
>
> Thanks,
>
> -Steven
>
>
> --
> Pmwiki-users mailing list
> Pmwiki-users at pmichaud.com
> http://pmichaud.com/mailman/listinfo/pmwiki-users_pmichaud.com
More information about the pmwiki-users
mailing list