Fix error index display
This commit is contained in:
parent
72176cf96c
commit
265b234dd6
2 changed files with 324 additions and 223 deletions
|
@ -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 @@ impl Formatter for HTMLFormatter {
|
|||
}
|
||||
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue