mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-13 22:32:35 +00:00
Fixes #156 - anchors are now URI encoded
also fixes https://github.com/rust-lang/book/issues/166 anchors duplication Thanks @azerupi for mentoring in #156 ! Cheers!
This commit is contained in:
parent
b6df992420
commit
b4948b680f
1 changed files with 3 additions and 1 deletions
|
@ -57,7 +57,9 @@ $( document ).ready(function() {
|
||||||
var wrapper = $("<a class=\"header\">");
|
var wrapper = $("<a class=\"header\">");
|
||||||
wrapper.attr("name", $(this).text());
|
wrapper.attr("name", $(this).text());
|
||||||
// Add so that when you click the link actually shows up in the url bar...
|
// Add so that when you click the link actually shows up in the url bar...
|
||||||
wrapper.attr("href", $(location).attr('href') + "#" + $(this).text());
|
// Remove any existing anchor then append the new one
|
||||||
|
// ensuring eg. no spaces are present within it ie. they become %20
|
||||||
|
wrapper.attr("href", $(location).attr('href').split("#")[0] + "#" + encodeURIComponent($(this).text().trim()) );
|
||||||
return wrapper;
|
return wrapper;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue