Description
Markup:
* MoinMoin:FrontPage#anchor broken * [[MoinMoin:some page#anchor]] broken * [[some page#anchor]] works * [[my #1 page#anchor]] works * [[C##|C#]] hackish, but works
Renders as:
FrontPage broken
some page broken
some page#anchor works
my #1 page#anchor works
C# hackish, but works
Note that for interwiki, the #anchor is seen as part of the pagename (because # is escaped), but for local links, it is split from the pagename and seen as an anchor (because # is not escaped).
Component selection
- wiki parser
Details
MoinMoin Version |
1.8.1 |
OS and Version |
|
Python Version |
|
Server Setup |
|
Server Details |
|
Language you are using the wiki in (set in the browser/UserPreferences) |
|
Workaround
Don't use anchors with interwiki links.
Discussion
The fundamental problem underlying is escaping. What shall we escape by default and what not?
- '#' can be part of the pagename, like "Mistake #1" - it is not meant to separate an anchor in this case and must be escaped in URL generation
'#' can be used to separate an anchor, like "LongPage#anchor" - in that case #anchor must be split off, then the pagename must be escaped and then #anchor must be appended to the generated URL
Please note that we not only have to think about # in pagenames, but also in filenames - as both will be just item names in a future moin. Depending on the backend or other requirements, filenames might be given by the filesystem, so we might have no influence on whether they contain # or not.
How to solve?
Forbid # in page names
If we do that, every # can be handled as an anchor separator.
But, there will be no pages about:
- C#
- Problem #1
- #define
- ...
Wiki engines doing it that way: mediawiki, oddmuse, jspwiki
Just use rightmost # as anchor separator
- foo#bar#baz would be referring to a page foo#bar with anchor baz
- C## would refer to a page C# with empty anchor
- Problem #1# would refer to page Problem #1 with empty anchor
- Problem #1#foo would refer to page Problem #1 with anchor foo
- and foo#bar#anchor#1 will refer to a page foo#bar#anchor with anchor #1 (instead of anchor anchor#1)??
- yes. # is invalid in anchor names anyway, right?
This is the solution for 1.8.x, implemented by http://hg.moinmo.in/moin/1.8/rev/af211e2f132c
The real solution (tm)
[[PageName|label|#anchor]]
[[PageName|label|&query=arg,#anchor]] combining qs and anchor, gives .../PageName?query=arg#anchor
[[|jump there|#anchor]] for target anchor on same page
[[|edit me|&action=edit]] link to action URL for same page
Should be done after BastianBlank's dom-refactoring repo is merged.
Short term consistency fix
For 1.8.1, 1.9 and 2.0 (dom stuff is likely to get merged after 2.0), we should make behaviour consistent.
I guess the easiest way is to handle interwiki like we handle local page links (i.e. just splitting pagename and anchor at the rightmost #). This just works for most cases and for the rare case you have a # in the pagename, you have to do the slightly dirty hack with the trailing #. As many other wikis do not allow # within the page name and that case is rather rare in general, that hack will be rarely used.
This is the solution for 1.8.x, implemented by http://hg.moinmo.in/moin/1.8/rev/af211e2f132c
Plan
- Priority:
- Assigned to:
- Status:
interwiki anchor link bug fixed by http://hg.moinmo.in/moin/1.8/rev/af211e2f132c
- "The real solution" should be implemented later, with the new dom parsers/formatters and with a new major release, because it changes link syntax.