response
[ikiwiki] / doc / todo / Short_wikilinks.mdwn
1 Markdown supports nice short links to external sites within body text by
2 references defined elsewhere in the source:
3
4         foo [bar][ref]
5
6         [ref]: http://example.invalid/
7
8 It would be nice to be able to do this or something like this for wikilinks
9 as well, so that you can have long page names without the links cluttering
10 the body text. I think the best way to do this would be to move wikilink
11 resolving after HTML generation: parse the HTML with a proper HTML parser,
12 and replace relative links with links to the proper files (plus something
13 extra for missing pages).
14
15 > That's difficult to do and have resonable speed as well. Ikiwiki needs to
16 > know all about all the links between pages before it can know what pages
17 > it needs to build to it can update backlink lists, update links to point
18 > to new/moved pages etc. Currently it accomplishes this by a first pass
19 > that scans new and changed files, and quickly finds all the wikilinks
20 > using a simple regexp. If it had to render the whole page before it was
21 > able to scan for hrefs using a html parser, this would make it at least
22 > twice as slow, or would require it to cache all the rendered pages in
23 > memory to avoid re-rendering. I don't want ikiwiki to be slow or use
24 > excessive amounts of memory. YMMV. --[[Joey]]
25
26 A related possibility would be to move a lot of "preprocessing" after HTML
27 generation as well (thus avoiding some conflicts with the htmlifier), by
28 using special tags for the preprocessor stuff. (The old preprocessor could
29 simply replace links and directives with appropriate tags, that the
30 htmlifier is supposed to let through as-is. Possibly the htmlifier plugin
31 could configure the format.)
32
33 > Or using postprocessing, though there are problems with that too and it
34 > doesn't solve the link scanning issue.
35
36 Other alternatives would be
37
38   * to understand the source format, but this seems too much work with all the supported formats; or
39
40   * something like the shortcut plugin for external links, with additional
41     support for specifying the link text, but the syntax would be much more
42     cumbersome then.
43
44 > I agree that a plugin would probably be more cumbersome, but it is very
45 > doable. It might look something like this:
46
47         \[[link bar]]
48
49         \[[link bar=VeryLongPageName]]