Skip to content

Commit 2c84e44

Browse files
authored
🎨 Hide empty content <div class="highlight*"> elements (#309)
2 parents cb4b483 + ca758c1 commit 2c84e44

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

‎docs/_sources/_static/custom.css‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@
1818
width: 100%;
1919
height: auto;
2020
}
21+
22+
/* empty content highlight divs ―
23+
see 'hideEmptyHighlights.js' */
24+
div[class*=" highlight"].hidden, div[class^=highlight].hidden {
25+
display: none;
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* Hide highlight containers only empty spans */
2+
document.addEventListener("DOMContentLoaded", function() {
3+
const highlightDivs = document.querySelectorAll('div[class^="highlight"], div[class*=" highlight"]');
4+
highlightDivs.forEach(function(highlightDiv) {
5+
if (highlightDiv.textContent.trim() === '') {
6+
highlightDiv.classList.add('hidden');
7+
}
8+
});
9+
});

‎docs/_sources/conf.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ def _unireplace(release_note, unireplace):
437437
'custom.css',
438438
]
439439
html_js_files = [
440+
'hideEmptyHighlights.js',
440441
('versionList.js', {'defer': 'defer'})]
441442

442443
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,

0 commit comments

Comments
 (0)