Skip to content

Commit

Permalink
Fix snippets hiding and buttons animation
Browse files Browse the repository at this point in the history
  • Loading branch information
pikinier20 committed Apr 4, 2022
1 parent a26a2c3 commit 95f6ef5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 24 additions & 1 deletion scaladoc/resources/dotty_res/scripts/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,30 @@ window.addEventListener("DOMContentLoaded", () => {

hljs.registerLanguage("scala", highlightDotty);
hljs.registerAliases(["dotty", "scala3"], "scala");
hljs.initHighlighting();

var aliases = ['language-scala', 'language-dotty', 'language-scala3']

var highlightDeep = function(el) {
el.childNodes.forEach(node => {
if(node.nodeType == Node.TEXT_NODE) {
let newNode = document.createElement('span');
newNode.innerHTML = hljs.highlight(node.textContent, {language: 'scala'}).value;
el.insertBefore(newNode, node);
el.removeChild(node);
} else if(node.nodeType == Node.ELEMENT_NODE) {
highlightDeep(node);
}
})
}

document.querySelectorAll('pre code').forEach( el => {
if (aliases.some(alias => el.classList.contains(alias))) {
highlightDeep(el);
} else {
hljs.highlightElement(el);
}
});


/* listen for the `F` key to be pressed, to focus on the member filter input (if it's present) */
document.body.addEventListener('keydown', e => {
Expand Down
1 change: 1 addition & 0 deletions scaladoc/resources/dotty_res/styles/scalastyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pre {
margin: 0px;
}
pre code, pre code.hljs {
font-family: var(--mono-font);
font-size: 1em;
padding: 0;
}
Expand Down

0 comments on commit 95f6ef5

Please sign in to comment.