@@ -59,7 +59,7 @@ impl HTMLFormatter {
59
59
) -> Result < ( ) , Box < dyn Error > > {
60
60
let mut output_file = File :: create ( parent_dir. join ( err_code) . with_extension ( "html" ) ) ?;
61
61
62
- self . header ( & mut output_file, "../" ) ?;
62
+ self . header ( & mut output_file, "../" , "" ) ?;
63
63
self . title ( & mut output_file, & format ! ( "Error code {}" , err_code) ) ?;
64
64
65
65
let mut id_map = IdMap :: new ( ) ;
@@ -90,7 +90,12 @@ impl HTMLFormatter {
90
90
self . footer ( & mut output_file)
91
91
}
92
92
93
- fn header ( & self , output : & mut dyn Write , extra : & str ) -> Result < ( ) , Box < dyn Error > > {
93
+ fn header (
94
+ & self ,
95
+ output : & mut dyn Write ,
96
+ extra_path : & str ,
97
+ extra : & str ,
98
+ ) -> Result < ( ) , Box < dyn Error > > {
94
99
write ! (
95
100
output,
96
101
r##"<!DOCTYPE html>
@@ -99,14 +104,14 @@ impl HTMLFormatter {
99
104
<title>Rust Compiler Error Index</title>
100
105
<meta charset="utf-8">
101
106
<!-- Include rust.css after light.css so its rules take priority. -->
102
- <link rel="stylesheet" type="text/css" href="{extra }rustdoc{suffix}.css"/>
103
- <link rel="stylesheet" type="text/css" href="{extra }light{suffix}.css"/>
104
- <link rel="stylesheet" type="text/css" href="{extra }rust.css"/>
107
+ <link rel="stylesheet" type="text/css" href="{extra_path }rustdoc{suffix}.css"/>
108
+ <link rel="stylesheet" type="text/css" href="{extra_path }light{suffix}.css"/>
109
+ <link rel="stylesheet" type="text/css" href="{extra_path }rust.css"/>
105
110
<style>
106
111
.error-undescribed {{
107
112
display: none;
108
113
}}
109
- </style>
114
+ </style>{extra}
110
115
</head>
111
116
<body>
112
117
"## ,
@@ -153,7 +158,22 @@ fn render_html(output_path: &Path, formatter: HTMLFormatter) -> Result<(), Box<d
153
158
create_dir_all ( & parent) ?;
154
159
}
155
160
156
- formatter. header ( & mut output_file, "" ) ?;
161
+ formatter. header (
162
+ & mut output_file,
163
+ "" ,
164
+ & format ! (
165
+ r#"<script>(function() {{
166
+ if (window.location.hash) {{
167
+ let code = window.location.hash.replace(/^#/, '');
168
+ // We have to make sure this pattern matches to avoid inadvertently creating an
169
+ // open redirect.
170
+ if (/^E[0-9]+$/.test(code)) {{
171
+ window.location = './{error_codes_dir}/' + code + '.html';
172
+ }}
173
+ }}
174
+ }})()</script>"#
175
+ ) ,
176
+ ) ?;
157
177
formatter. title ( & mut output_file, "Rust Compiler Error Index" ) ?;
158
178
159
179
write ! (
0 commit comments