[Mediawiki-l] Linking to page sections

Brion Vibber brion at pobox.com
Sun Dec 10 08:32:15 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kasimir Gabert wrote:
> Anchors work in HTML through the name attribute on an <a tag.  This
> means that if you want to have a link to "Earp, Wyatt (1848-1929)",
> you need to have something such as
> 
> <a name="EW1">&nbsp;</a>'''Earp, Wyatt (1848-1929)'''<br />
> 
> Because MediaWiki does not allow HTML's <a> tags directly (and you do
> not want that), then you can make a simple extension such as the
> following:

No extension is necessary; unless your readers are all using ancient
versions of Mosaic or Netscape Navigator, you can just use a <div> or
other allowed element and set the id attribute, as in the original
poster's example.

    Destination anchors in HTML documents may be specified
    either by the A element (naming it with the name attribute),
    or by any other element (naming with the id attribute).

    http://www.w3.org/TR/html4/struct/links.html#h-12.1.1

Note that there is some funky normalization of anchor names on wikilinks
due to the strict rules for the id attribute in XML (and hence XHTML
1.0; MediaWiki produces XHTML 1.0 Transitional following HTML 4
compatibility recommendations), so do test that your custom anchor ids
work correctly.

- -- brion vibber (brion @ pobox.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFe8YPwRnhpk1wk44RAlD3AJ9Ubs2vnNMr+aG+NqekMBrh6A0PbgCeJyQp
9yUTwC+pHacjfTx7hrkSHVM=
=EMkd
-----END PGP SIGNATURE-----



More information about the MediaWiki-l mailing list