[ewiki] Re: Custom link formats
- From: Mike Payson <mpayson@xxxxxxxxxxxx>
- To: ewiki@xxxxxxxxxxxxx
- Date: Sat, 27 Nov 2004 23:56:43 -0800
One more problem I just discovered. When I fixed the http links so they work
(they were not inserting the http://), they are now being parsed by the
regular link engine & replaced, so you end up with:
<a href="<a class="url http notfound
href="http://www.amazon.com">http://www.amazon.com</a>"
target="_SELF">Amazon</a>
How can I suppress the default behavior on this?
On Saturday 27 November 2004 11:42 pm, Mike Payson wrote:
> Ok, I've almost got it. I'm having a problem, though. The Wiki source below
> returns the output, further below. The first item is fine, the second item
> is doubled, the third item is tripled & the fourth... I obviously don't
> quite get what's going on here. If I got it right (obviously I didn't!) the
> regex's go from most strict to least, so each option should only match
> once. Once they match, the [! ] markup will be replaced, so I don't get why
> things are being duplicated. Can anyone spot where I went wrong?
>
>
> The Wiki source:
> *[!http://www.amazon.com | Amazon]
> *[!Wikiness | Wiki Details]
> *[!http://www.dawgdayz.com]
> *[!Wikiness]
>
>
> The output:
> <li><a href="www.amazon.com" target="_SELF">Amazon</a></li>
> <li><a href="Wikiness" target="_SELF">Wiki Details</a><a
> href="index.php?page=Wikiness" target="_SELF">Wiki Details</a></li>
> <li><a href="www.dawgdayz.com" target="_SELF"></a><a
> href="index.php?page=www.dawgdayz.com" target="_SELF"></a><a
> href="www.dawgdayz.com" target="_SELF">www.dawgdayz.com</a></li>
> <li><a href="Wikiness" target="_SELF"></a><a href="index.php?page=Wikiness"
> target="_SELF"></a><a href="Wikiness" target="_SELF">Wikiness</a><a
> href="index.php?page=Wikiness" Target="_SELF">Wikiness</a> </li>
>
>
> And, the php code:
> <?php
> $ewiki_plugins["format_source"][] = "ewiki_format_source_selflinks";
>
> function ewiki_format_source_selflinks (&$src) {
> # http url with title
> $rx = "/\[!http:\/\/(.*?) \| (.*?)]/";
> $rep .= "<a href=\"$1\" target=\"_SELF\">$2</a>";
> $src = preg_replace( $rx, $rep, $src);
> # Wikiword with specified title
> $rx = "/\[!(.*?) \| (.*?)]/";
> $rep .= "<a href=\"index.php?page=$1\" target=\"_SELF\">$2</a>";
> $src = preg_replace( $rx, $rep, $src);
> # http url without title
> $rx = "/\[!http:\/\/(.*?)]/";
> $rep .= "<a href=\"$1\" target=\"_SELF\">$1</a>";
> $src = preg_replace( $rx, $rep, $src);
> # Wikiword without specified title
> $rx = "/\[!(.*?)]/";
> $rep .= "<a href=\"index.php?page=$1\" Target=\"_SELF\">$1</a>";
> $src = preg_replace( $rx, $rep, $src);
> }
> ?>
>
> On Saturday 27 November 2004 4:47 pm, Mike Payson wrote:
> > I'm working on a wiki that will be used in the browser sidebar as a
> > cross-platform, multi-computer bookmark & notekeeping tool. To make this
> > work, I need to add two custom link formats.
> >
> > First, I need to be able to specify that certain links will include a
> > 'target="_SELF"' attribute. My plan is to use a syntax such as
> > [!WikiWord] for these links (these will usually be wikiwords, but may
> > occasionally be external links). The second format would tell the wiki to
> > retrieve the site icon for external links and display it.
> >
> > I can code these, but I'm somewhat baffled as to where to begin. Are
> > there any plugins that do anything similar that I can use as an example
> > of how to do this? If not, can someone give me any pointers?
> >
> > Thanks!
- References:
- [ewiki] Custom link formats
- From: Mike Payson
- [ewiki] Re: Custom link formats
- From: Mike Payson
Other related posts:
- » [ewiki] Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- » [ewiki] Re: Custom link formats
- [ewiki] Custom link formats
- From: Mike Payson
- [ewiki] Re: Custom link formats
- From: Mike Payson