Skip to content

Commit 6cf436c

Browse files
committed
fix: output=asis code cells weren't folded by code-tools
1 parent 9e9160b commit 6cf436c

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/resources/formats/html/templates/quarto-html-after-body.ejs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,9 @@
149149
}
150150
function toggleCodeHandler(show) {
151151
return function(e) {
152-
const detailsSrc = window.document.querySelectorAll(".cell > details > .sourceCode");
153-
for (let i=0; i<detailsSrc.length; i++) {
154-
const details = detailsSrc[i].parentElement;
155-
if (show) {
156-
details.open = true;
157-
} else {
158-
details.removeAttribute("open");
159-
}
160-
}
161-
const cellCodeDivs = window.document.querySelectorAll(".cell > .sourceCode");
162-
const fromCls = show ? "hidden" : "unhidden";
163-
const toCls = show ? "unhidden" : "hidden";
164-
for (let i=0; i<cellCodeDivs.length; i++) {
165-
const codeDiv = cellCodeDivs[i];
166-
if (codeDiv.classList.contains(fromCls)) {
167-
codeDiv.classList.remove(fromCls);
168-
codeDiv.classList.add(toCls);
169-
}
170-
}
171-
return false;
152+
document.querySelectorAll("details.code-fold").forEach((details) => {
153+
details.toggleAttribute("open", show);
154+
});
172155
}
173156
}
174157
const hideAllCode = window.document.getElementById("quarto-hide-all-code");
@@ -681,4 +664,4 @@
681664
682665
</script>
683666
<% } %>
684-
667+

0 commit comments

Comments
 (0)