Skip to content

Commit 9b4c53b

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

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ All changes included in 1.9:
1717
- ([#13633](https://github.com/quarto-dev/quarto-cli/issues/13633)): Fix detection and auto-installation of babel language packages from newer error format that doesn't explicitly mention `.ldf` filename.
1818
- ([#13694](https://github.com/quarto-dev/quarto-cli/issues/13694)): Fix `notebook-view.url` being ignored - external notebook links now properly use specified URLs instead of local preview files.
1919
- ([#13732](https://github.com/quarto-dev/quarto-cli/issues/13732)): Fix automatic font package installation for fonts with spaces in their names (e.g., "Noto Emoji", "DejaVu Sans"). Font file search patterns now match both with and without spaces.
20+
- ([#14120](https://github.com/quarto-dev/quarto-cli/pull/14120)): Fix code-tools show/hide all code buttons, and allow them to act on cells with `output: asis`
2021

2122
## Dependencies
2223

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)