Book: weird # behaviour (anchors)

Created on 30 Jul 2016  路  3Comments  路  Source: rust-lang/book

preamble:

Linking to anchors is very similar to normal links. Normal links always point to the top of a page. Anchors point to a place within a page.

If you click on eg. this link: https://rust-lang.github.io/book/ch04-02-ownership.html#Ownership
and then you click on Ownership again, then the url gets #Ownership appended again so it looks like this:
https://rust-lang.github.io/book/ch04-02-ownership.html#Ownership#Ownership
now if you load that link and click Ownership you get a third #Ownership appended.

In other words, it doesn't check to see if the loaded url already has #Ownership appended.

Note that if more than one anchor is present in the url, then the position is the top of the page instead, eg.
https://rust-lang.github.io/book/ch04-02-ownership.html#Variable binding scope#Variable binding scope#Strings
EDIT: anchors with spaces: https://github.com/azerupi/mdBook/issues/156

This might be chromium's fault, I'm not sure.

Chromium    54.0.2814.0 (Developer Build) (64-bit)
Revision    7077c9c09ee068bfeb7623c8ac58e7a21b7143c8-refs/heads/master@{#408870}
OS  Linux 
JavaScript  V8 5.4.301

An example of a working anchor that by using the above steps doesn't double the anchor, which suggests it's not chromium's fault:
https://github.com/rust-lang/rust-playpen#running-your-own-rust-playpen

All 3 comments

It also might just be an mdbook bug; /cc @azerupi

I pushed a new version to crates.io that contains the fix

This is indeed fixed and on http://rust-lang.github.io/book/ now!! Thank you!!!

Was this page helpful?
0 / 5 - 0 ratings