Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki.git] / doc / ikiwiki / wikilink / discussion.mdwn
1 # Creating an [[anchor]] in Markdown
2
3 Is it a native Markdown "tag" for creating an [[anchor]]? Unfortunately,
4 I haven't any information about it at
5 [Markdown syntax](http://daringfireball.net/projects/markdown/syntax) page.
6
7 Of course, I know that I can use HTML tag to do it,
8 for example <a name="foo" />, but I don't want to mix Markdown
9 and HTML code if it's not necessary.
10
11 BTW, ikiwiki doesn't displays the #foo anchor in the example
12 ("To link to an anchor inside a page...") at [[WikiLink]] page...
13
14 --[[Paweł|ptecza]]
15
16 > No such syntax exists in markdown.  ikiwiki could certainly have a
17 > [[preprocessor_directive|directive]] for it, though.
18 > --[[JoshTriplett]]
19
20 >> [[!tag wishlist]]
21 >> I'd like to implement such a thing.  Joey, what is this supposed to look like?
22 >> `\[[anchor WHATEVER]]`?  --[[tschwinge]]
23
24 >>> Why would you want to use a preprocessor directive for something that can
25 >>> be more shortly and clearly done with plain HTML? Markdown is *designed*
26 >>> to be intermixed with HTML. --[[Joey]]
27
28 >>>> I tend to disagree.
29 >>>> It just doesn't feel right for me to put HTML code straight into Markdown files.
30 >>>>
31 >>>> Quoting <http://daringfireball.net/projects/markdown/>:
32 >>>>
33 >>>>> The idea is that a Markdown-formatted document should be publishable as-is, as plain text, *without looking like it’s been marked up with tags or formatting instructions*.
34 >>>>
35 >>>> Also, in theorie at least, Markdown might also support other output formats than HTML.
36 >>>> Those wouldn't know about how to deal with the intermingled HTML code.
37 >>>>
38 >>>> --[[tschwinge]]
39 >>>>>Not sure \[[anchor WHATEVER]] looks any better than &lt;a name="WHATEVER"&gt;...?  --[[sabr]]
40
41 > The lack of the `#foo` anchor in the anchor example on [[wikilink]]
42 > definitely looks like a bug.  --[[JoshTriplett]]
43
44 >> Fixed that --[[Joey]]
45
46 The 'name' attribute of the 'a' element is a depracated way to create a named anchor. The right way to do that is using the 'id' attribute of any element. This is because an anchor may refer to a complete element rather than some point in the page.
47
48 Standard purity aside, if you define an anchor (using either 'a name' or 'id') to a single point in the document but refer to a complete section, the browser may just show that specific point at the bottom of the page rather than trying to show all the section.
49 --[[tzafrir]]
50
51 ---
52
53 Considering a hierarchy like `foo/bar/bar`, I had the need to link from the
54 `foo/bar/bar` page to the `foo/bar` one.  It would have been convenient to
55 simply write [[wikilink]]s like `\[[../bar]]` (or even just `\[[..]]`?), but
56 this doesn't work, so I had to resort to using `\[[foo/bar]]` instead.
57 --[[tschwinge]]
58
59 > I believe, that doesn't entirely solve the problem. Just assume, your hierarchy is `/foo/bar/foo/bar`.
60
61 > How do you access from the page `/foo/bar/foo/bar` the `/foo/bar` and not `/foo/bar/foo/bar`?
62
63 > Do we have a way to implement `\[[../..]]` or `\[[/foo/bar]]`?
64
65 > Even worse, trying to link from `/foo/bar` to `/foo/bar/foo/bar` ... this will probably need `\[[./foo/bar]]` --[[Jan|jwalzer]]
66
67 >> There is no ".." syntax in wikilinks, but if the link begins with "/" it
68 >> is rooted at the top of the wiki, as documented in
69 >> [[subpage/linkingrules]]. Therefore, every example page name you listed
70 >> above will work unchanged as a wikilink to that page! --[[Joey]]
71
72 ----
73
74 How do I make images clickable?  The obvious guess, \[[foo.png|/index]], doesn't work.  --[[sabr]]
75
76 > You can do it using the img plugin. The syntax you suggested would be ambiguous,
77 > as there's no way to tell if the text is meant to be an image or displayed as-is.
78 > --[[Joey]]
79
80 ----
81
82 Is it possible to refer to a page, say \[[foobar]], such that the link text is taken from foobar's title [[directive/meta]] tag? --Peter
83
84 > Not yet. :-) Any suggestion for a syntax for it? Maybe something like \[[|foobar]] ? --[[Joey]]
85
86 I like your suggestion because it's short and conscise. However, it would be nice to be able to refer to more or less arbitrary meta tags in links, not just "title". To do that, the link needs two parameters: the page name and the tag name, i.e. \[[pagename!metatag]]. Any sufficiently weird separater can be used instead of '!', of course. I like \[[pagename->metatag]], too, because it reminds me of accessing a data member of a structure (which is what referencing a meta tag is, really). --Peter
87
88 > I dislike \[[pagename->metatag]] because other wikis use that as their normal link/label syntax.
89 > I'm not sure that it is a good idea to refer to arbitrary meta tags in links in the first place - what other meta tags would you really be interested in?  Description?  Author?  It makes sense to me to refer to the title, because that is a "label" for a page.
90 > As for syntax, I do like the \[[|foobar]] idea, or perhaps something like what <a href="http://www.pmwiki.org">PmWiki</a> does - they have their links the other way around, so they go \[[page|label]] and for link-text-as-title, they have \[[page|+]].  So for IkiWiki, that would be \[[+|page]] I guess.
91 > --[[KathrynAndersen]]