提交 8fbfd2c9 编写于 作者: C Corey Farwell 提交者: GitHub

Rollup merge of #47301 - GuillaumeGomez:fix-error-index-display, r=QuietMisdreavus

Fix error index display

Fixes #47284.

r? @QuietMisdreavus
......@@ -206,7 +206,7 @@ pre {
padding: 14px;
padding-right: 0;
margin: 20px 0;
font-size: 13px;
font-size: 15px;
word-break: break-all;
}
code {
......@@ -416,3 +416,46 @@ a.test-arrow:hover{
margin-left: 2em;
margin-bottom: 1em;
}
.error-described {
position: relative;
}
.information {
position: absolute;
left: -25px;
margin-top: 7px;
z-index: 1;
}
.tooltip {
position: relative;
display: inline-block;
cursor: pointer;
}
.tooltip .tooltiptext {
width: 120px;
display: none;
text-align: center;
padding: 5px 3px;
border-radius: 6px;
margin-left: 5px;
top: -5px;
left: 105%;
z-index: 1;
}
.tooltip:hover .tooltiptext {
display: inline;
}
.tooltip .tooltiptext::after {
content: " ";
position: absolute;
top: 50%;
left: 13px;
margin-top: -5px;
border-width: 5px;
border-style: solid;
}
......@@ -109,7 +109,65 @@ fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
}
fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
write!(output, "</body>\n</html>")?;
write!(output, r##"<script>
function onEach(arr, func) {{
if (arr && arr.length > 0 && func) {{
for (var i = 0; i < arr.length; i++) {{
func(arr[i]);
}}
}}
}}
function hasClass(elem, className) {{
if (elem && className && elem.className) {{
var elemClass = elem.className;
var start = elemClass.indexOf(className);
if (start === -1) {{
return false;
}} else if (elemClass.length === className.length) {{
return true;
}} else {{
if (start > 0 && elemClass[start - 1] !== ' ') {{
return false;
}}
var end = start + className.length;
if (end < elemClass.length && elemClass[end] !== ' ') {{
return false;
}}
return true;
}}
if (start > 0 && elemClass[start - 1] !== ' ') {{
return false;
}}
var end = start + className.length;
if (end < elemClass.length && elemClass[end] !== ' ') {{
return false;
}}
return true;
}}
return false;
}}
onEach(document.getElementsByClassName('rust-example-rendered'), function(e) {{
if (hasClass(e, 'compile_fail')) {{
e.addEventListener("mouseover", function(event) {{
e.previousElementSibling.childNodes[0].style.color = '#f00';
}});
e.addEventListener("mouseout", function(event) {{
e.previousElementSibling.childNodes[0].style.color = '';
}});
}} else if (hasClass(e, 'ignore')) {{
e.addEventListener("mouseover", function(event) {{
e.previousElementSibling.childNodes[0].style.color = '#ff9200';
}});
e.addEventListener("mouseout", function(event) {{
e.previousElementSibling.childNodes[0].style.color = '';
}});
}}
}});
</script>
</body>
</html>"##)?;
Ok(())
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册