[Pmwiki-users] Idea for syntax of linking to an anchor within a page

Patrick R. Michaud pmichaud
Sat Aug 16 11:09:49 CDT 2003


On Sat, Aug 16, 2003 at 06:26:10PM +0200, Christian Ridderstr?m wrote:
> Hi
> 
> I was trying to create link to an anchor within the current page, and 
> eventually came up with these two solutions:
> 
> (1)	[[ThisPage:#Anchor link text]]
> (2)	[[http:#Anchor link text]]

As of version 0.5.15 you can do PageName#anchor, where PageName is the
name of the page you want to anchor to.  So you can just reuse the current
pagename in the anchor.

> Questions:
> 	- Is [[http:#Anchor ]] supposed to work?
> 	- If not, is it safe to use it? (or will it disappear in 
> 	  future versions)

It's very browser dependent.  What happens is that it gets translated
into html that looks like  <a href='http:#Anchor'>link text</a>, and
some browsers definitely cannot handle the url properly.  So, I wouldn't
consider it safe--not because PmWiki will ever get rid of it, but just
because it doesn't work in all browsers.

> Otherwise I'd like to suggest that the anchor link could be written as:
> 	[[#Anchor link text]]
> Spaces doesn't work as anchor names anyway (unless maybe we start adding 
> %20 or something?).

This is just a bit tricky in the current markup, because [[#Anchor]] 
is currently being used to define an anchor.  Thus we'd have the following
situation:

   [[WikiWord]]             - link to WikiWord, renders as "[1]"
   [[WikiWord link text]]   - link to WikiWord, renders as "link text"
   [[#Anchor]]              - defines an anchor, renders nothing
   [[#Anchor link text]]    - link to #Anchor, renders as "link text"
   [[WikiWord#Anchor]]      - link to WikiWord#Anchor, renders as "[2]"
   [[WikiWord#Anchor text]] - link to WikiWord#Anchor, renders as "text"
   #Anchor                  - neither a link nor anchor--renders as "#Anchor"

It just seems a bit irregular to me:
   WikiWord links to a page named WikiWord, 
   WikiWord#Anchor links to #Anchor within a page named WikiWord,
   [[WikiWord text]] links to WikiWord with "text", 
   [[WikiWord#Anchor text]] links to WikiWord#Anchor with "text",
   [[#Anchor text]] links to #Anchor in the current page with "text",
but
   [[#Anchor]] is not a link, even though [[#Anchor text]] and [[WikiWord]] 
       are, and 
   #Anchor is not a link, even though WikiWord#Anchor is.

(Note: I'm going to remain fairly adamant that #Anchor alone in the markup
text not be treated as a link, because #text can often occur where it's
not intended to be a link.)

On the other hand, even though [[#Anchor link text]] is irregular it does
seem fairly intuitive--i.e., I don't think it would confuse authors.  It
would also greatly simplify the implementation and generation of links
to targets on the same page.  Currently PmWiki generates links that cause
browsers to reload the page--i.e., <a href='http://.../PageName#Anchor'>
instead of a simple <a href='#Anchor'>.

I definitely need to hear opinions/votes on this before I commit to 
anything--either respond to the listserv or mail me directly so 
I can have some idea of how others feel about the proposal.

Pm



More information about the pmwiki-users mailing list