mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
rustdoc: percent-encode URL fragments
This commit is contained in:
@@ -582,6 +582,7 @@ fn next(&mut self) -> Option<Self::Item> {
|
||||
}
|
||||
}
|
||||
let id = self.id_map.derive(id);
|
||||
let percent_encoded_id = small_url_encode(id.clone());
|
||||
|
||||
if let Some(ref mut builder) = self.toc {
|
||||
let mut text_header = String::new();
|
||||
@@ -596,8 +597,9 @@ fn next(&mut self) -> Option<Self::Item> {
|
||||
std::cmp::min(level as u32 + (self.heading_offset as u32), MAX_HEADER_LEVEL);
|
||||
self.buf.push_back((Event::Html(format!("</h{level}>").into()), 0..0));
|
||||
|
||||
let start_tags =
|
||||
format!("<h{level} id=\"{id}\"><a class=\"doc-anchor\" href=\"#{id}\">§</a>");
|
||||
let start_tags = format!(
|
||||
"<h{level} id=\"{id}\"><a class=\"doc-anchor\" href=\"#{percent_encoded_id}\">§</a>"
|
||||
);
|
||||
return Some((Event::Html(start_tags.into()), 0..0));
|
||||
}
|
||||
event
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#![crate_name = "unicode"]
|
||||
|
||||
pub struct Foo;
|
||||
|
||||
impl Foo {
|
||||
//@ has unicode/struct.Foo.html //a/@href "#%C3%BA"
|
||||
//@ !has unicode/struct.Foo.html //a/@href "#ú"
|
||||
/// # ú
|
||||
pub fn foo() {}
|
||||
}
|
||||
Reference in New Issue
Block a user