Skip to content

Instantly share code, notes, and snippets.

@gadenbuie
Created October 22, 2020 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gadenbuie/0f46ab12fe81ea8ff8df0ca875e9f1ce to your computer and use it in GitHub Desktop.
Save gadenbuie/0f46ab12fe81ea8ff8df0ca875e9f1ce to your computer and use it in GitHub Desktop.
(function() {
var divHTML = document.querySelectorAll(".details");
divHTML.forEach(function (el) {
let title = [...el.classList].filter(s => !s.match(/details|open/))
el.outerHTML = '<details ' +
(el.classList.contains("open") ? "open " : "") +
'class="output"><summary>' +
(title.length ? title : 'Details') +
'</summary>' +
el.innerHTML +
'</details>';
})
})();
@gadenbuie
Copy link
Author

For xaringan slides, converts something like

.details.Answer[
The answer is here...
]

into

<details><summary>Answer</summary>
The answer is here...
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment