Skip to content

Commit

Permalink
Add page role for avoiding code blocks collapse. (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-ottolenghi authored Oct 11, 2023
1 parent 671e012 commit 74a449e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/06-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { createElement } from './modules/dom'
})()

document.addEventListener('DOMContentLoaded', function () {
var body = document.querySelectorAll('body')
var ignore = ['gram']

var cleanCode = function (code, language) {
Expand Down Expand Up @@ -219,7 +220,7 @@ document.addEventListener('DOMContentLoaded', function () {
var listingBlock = dotContent.parentNode
var code = pre.querySelector('code')

if (!listingBlock.classList.contains('nocollapse') &&
if (!(listingBlock.classList.contains('nocollapse') || body.classList.contains('code-nocollapse')) &&
pre.offsetHeight > (codeMaxLines + codeTolerance) * codeLineHeight) {
pre.style.maxHeight = codeMaxHeight + 'px'
pre.style.overflow = 'hidden'
Expand Down

0 comments on commit 74a449e

Please sign in to comment.