From 74a449e09745dac606b95a4a34c41ea99823dc94 Mon Sep 17 00:00:00 2001 From: Stefano Ottolenghi Date: Wed, 11 Oct 2023 06:43:37 +0200 Subject: [PATCH] Add page role for avoiding code blocks collapse. (#195) --- src/js/06-code.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/06-code.js b/src/js/06-code.js index 0991dc44..7dc4acf9 100644 --- a/src/js/06-code.js +++ b/src/js/06-code.js @@ -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) { @@ -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'