You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Collapsible contents (code block) in comments / spoiler tag #166
GitHub really needs a way to collapse long contents. Being able to collapse entire comments may suffice for most. To me however, the ideal solution would be to collapse any code block with more than 10 lines (or whatever number) by default. The code block would be replaced by the text:
Code (130 lines) - Expand
Where clicking "Expand" reveals the code block. Being able to specify a collapsible code block with ````collapse` would work equally as well. I recall reading a discussion about this feature involving some GitHub developers. I can't find the link to that discussion, but their response at the time was "We'll implement it when CommonMark does."
Perhaps it's time to stop waiting for CommonMark to change and simply add this functionality to GitHub's Web UI; no MarkDown hacks required.
Reacted by Andrew Ensley, lesander, George, Samantha, Jan Hybš, Sundeep Paruvu, Rob Garrison, Jakub Sygnowski, Alexander Rodionov, John Vandenberg and 251 more
Reacted by dzza, Lucent (Changyoung Koh), Che Fisher, Dominic Farolino, Ilia Smirnov, Maris, Alec Larson, Jason Axelson, Unknown6656, toriiico and 15 more
Reacted by Gleb Liutsko, Patrick Kaman, Onkar Ganjewar, Hei Liebrecht and Y. Serdar Çalışkan
Reacted by Eliot Cole, STGamer24YT and Y. Serdar Çalışkan
Reacted by Andrew Ensley, Polina Filipova, Dani Hodovic, Jakub Jirutka, qindan2008, Bluscream, Keenan Phillips, Serghei Iakovlev, Johannah Sprinz, Pavel Dzunovich and 38 more
Reacted by dzza, Equipo5, Kevin Cox, xan and Wayne Rocha
@Mottie That is fantastic! That is exactly what I'm looking for. Any chance you could turn that into Chrome Extension so that it could be synced across browsers?
If you setup your Google account on Google Chrome, it can sync extensions and settings between different instances of Google Chrome (laptop, desktop, chromebook, etc.)
And now that I think about, it might be a bit more painful than I initially thought. If I make more than one addon, I'll need to move each userscript into its own subdirectory with a manifest.json. That might take a bit longer.
Reacted by Andrew Ensley, thatsIch, Nick Kapliev, Alan and OrangeC7
Reacted by Andrew Ensley, Robert Lech, José Cage , Nick Kapliev, j2shnz, Franco Laiuppa, qindan2008, Colin Marshall, Alex Terehov, Nathan Basanese and 11 more
Reacted by Simen Bekkhus, Andrew Ensley, Dean Perry, José Cage , Seg, j2shnz, qindan2008, Autumn (Bee), Evgeniy Trifonov, vivaan.bhatia and 3 more
Reacted by Simen Bekkhus, Andrew Ensley, qindan2008, Autumn (Bee), Abhijat, vivaan.bhatia, Alex, Equipo5, Giorgos Xanthopoulos and Aarón Rodríguez
For what it's worth, collapsible sections are supported:
Click to expand
<details><summary>Click to expand</summary>
whatever
</details>
Reacted by Tim D. Smith, Alec Zopf, Alec Larson, Toby Jackson, Mahesh Peddipaga, Andrew Meyer, Aref Shafaei, Jakub Sygnowski, Jeroen Visser, Stephan van Stekelenburg and 693 more
Reacted by Vasyl Boroviak, Melanie Cooper, José Cage , Dmitry Petukhov, Jörn Friedrich Dreyer, Antoine Cotten, Frank Orellana, Richard Forth, upgradeQ, Luca Steeb and 153 more
Reacted by Alec Zopf, Stephan van Stekelenburg, samuel, Justin Adler, Aaron Virshup, Stephane Plaisance, Pavel Zhovner, Mark Tompkins, Thai Pangsakulyanont, Melanie Cooper and 125 more
Reacted by Josua M C, Maksym Grebenets, informer2016, Ivan Tse, Vitalii Kozlovskyi, Amit Kulkarni and Michael Duane Mooring
Reacted by Mackenzie Ewing, upgradeQ, Luca Steeb, Patrick Kennedy, Stephen Russett, Troy Alford, Anton Kulikalov, Oleksii Shtanko, Kevin Ingelman, Lukas Kollmer and 113 more
Reacted by xgqfrms, Philip Durbin, Tony Ko, Dimentive, Michael Sanford, Linus Behrbohm, Tristan, Pilatte, Ivan Larin, XANDER and 4 more
Reacted by xgqfrms, Philip Durbin, Tony Ko, Dimentive, Yves M., R4SAS, Michael Sanford, Pilatte, Edward Longman, XANDER and 3 more
The key is to wrap the whole contents inside the <p>:
<details><summary>stuff with *mark* **down**</summary><p>
## _formatted_ **heading** with [a](link)
---
{{standard 3-backtick code block omitted from here due to escaping issues}}
---
Collapsible until here.
</p></details>
Reacted by Даниил Пронин, Tyler Collier, Perry, Shanon Levenherz, William Ting, Marek Grzybek, Eric McCormick, Thinh Nguyen, Bryce Hanscomb, Rett Berg and 227 more
Reacted by informer2016, snwatson, Edward Longman, dludtke-zd and GJoe2
Reacted by Даниил Пронин, Oleksandr Garagatyi, Andrei Glingeanu, Darina, Dominique Müller, R Max Espinoza, Antoine Cotten, Jyan, jithin, Josh and 27 more
Reacted by informer2016
Reacted by Jesse Ditson, Antoine Cotten, Patrick Kennedy, Paul Fenwick, Alvaro Pinot @alvaropinot, Josh, KOLANICH, Matt Holt, Vitalii Lebediev, Rubens Mariuzzo and 47 more
Reacted by Rob Garrison, Evgeniy Trifonov, Abhijat, Edipo Vinicius da Silva, informer2016, JaDoggx86, Ma'ruf Shidiq, lovetoburnswhen, KlarkC and Alex Nguyen
Reacted by Chris Chang, Julian Reyes Escrigas, Rui Azevedo, Miguel C, Andrew Mead, Tomas, informer2016, Jacob Gustafson, Michael Pfaff, Eduardo Campaña and 1 more
Reacted by Nick Palenchar, Richard Forth, Luca Steeb, Oleg Solomko, Camilo Aguilar, Phil McClure, Guillaume Raffin, Yukai Huang, Federico Zivolo, David Birks and 23 more
Reacted by Chris Chang, Gaurang Tandon, liquidpele, Sergei Zharkov, Thibaut, Petr, pugson, Ethan Lin, informer2016, Michael Pfaff and 2 more
Reacted by Dan Esparza, Manoj Chandrashekar, Augustin Berisa, João Neto, Tomsgu, informer2016, matthias-t, Shahriyar Guliyev, Maris, Uglješa Erceg and 8 more
Reacted by informer2016, Tim McConechy and CJ
Reacted by Bluscream, informer2016, Konstantin Portnov, XANDER, Nicholas Guyett and Philip Orlando
@caseydwayne I object to closing, I don't think of <details> as a solution, more like a workaround/hack. It's HTML after all, not GFM. It has issues, like not being cross-browser and non-trivial nesting of code blocks I pointed out above.
Reacted by Andrew Ensley, Minz, Larry Guo, Kamil Dziedzic, Stefan Wójcik, Michael Ovchinnikov, Wout Mertens, Pavel Selivanov, Edric Chan, skwerlman and 42 more
some

At Wiki this won't show, at issue comment here it works:
Reacted by Vitaliy Novichkov, Matronator, Nelson Martell, Luke Bailey, Max, XANDER, Jim Grisham, Svyatoslav Fyodorov, Yaroslav Krivushenko, Alexey and 2 more
Reacted by Yaroslav Krivushenko and Simon Entholzer
@Berchon what does "doesn't work" mean in your case? I tried Android Chrome and it was hard to expand because we can't click on the link or the arrow, only on the right side of the line. After that it jumps to heading as expected. I guess adding more (unlinked) text would make this better. Note: the empty line after summary and before details is sometimes very important.
How can I use checkmarks inside spoiler? This is a checkmark:
Click me to toggle checked state
Where * [ ] starts an unchecked, and * [x] starts a checked line.
However inside the spoiler, toggling state will collapse the spoiler..!
Open me and check three marks!
This is especially troublesome in longer spoilers than I showed above. You will loose the scroll-state, and need to click much more than thrice.
Is there any shortcut / autocomplete / button to spawn a <detail> tag, ready to be filled in?
I hate that every time I have to look it up or type it down!
@PieterjanDeClippel yes it does. The point in recent conversations is that a UI interaction is better than manual typing/Google-copy-paste, an interaction would ideally take care of annoyances like remembering to insert those new lines.
Reacted by Pieterjan, a-pav, Nelson Martell, Kebap and Sayvai
Activity
Mottie commentedon Jun 27, 2016
In case you're interested, I just created a userscript to collapse code & long quote blocks in comments.
aensley commentedon Jun 28, 2016
@Mottie That is fantastic! That is exactly what I'm looking for. Any chance you could turn that into Chrome Extension so that it could be synced across browsers?
Mottie commentedon Jun 28, 2016
That shouldn't be a problem, but what do you mean by "synced across browsers"?
aensley commentedon Jun 28, 2016
If you setup your Google account on Google Chrome, it can sync extensions and settings between different instances of Google Chrome (laptop, desktop, chromebook, etc.)
Mottie commentedon Jun 28, 2016
Oh, you can do that with Tampermonkey's TESLA.
And now that I think about, it might be a bit more painful than I initially thought. If I make more than one addon, I'll need to move each userscript into its own subdirectory with a manifest.json. That might take a bit longer.
Mottie commentedon Jul 4, 2016
Ok, I finally got around to creating a Chrome extension. Enjoy!
https://github.com/Mottie/Octopatcher
ide commentedon Jul 30, 2016
For what it's worth, collapsible sections are supported:
Click to expand
Mottie commentedon Jul 30, 2016
@ide The
detailsblock won't work in Firefox until v49 (see necolas/normalize.css#604).Mottie commentedon Sep 21, 2016
Firefox v49 is now live (since yesterday)!
TWiStErRob commentedon Oct 7, 2016
Building on @ide's answer, here's how to handle code blocks inside
<details>:stuff with _mark_ **down**
formatted heading with a
Collapsible until here.
The key is to wrap the whole contents inside the
<p>:For more details see: http://stackoverflow.com/a/39920717/253468
noam3127 commentedon Dec 25, 2016
Though not directly related to this discussion, I just published a handy new Chrome extension that enables code-folding when viewing files in GitHub and I hope many people find it as useful as I do. Works for any indentation style - tabs, 2 spaces, 4 spaces, etc. https://github.com/noam3127/github-code-folding
Bluscream commentedon Dec 30, 2016
Click to expand
whatevercaseydwayne commentedon Jan 3, 2017
Solution provided above.
Search not, future seekers. Close issue?
TWiStErRob commentedon Jan 3, 2017
@caseydwayne I object to closing, I don't think of
<details>as a solution, more like a workaround/hack. It's HTML after all, not GFM. It has issues, like not being cross-browser and non-trivial nesting of code blocks I pointed out above.Fix code blocks per dear-github/dear-github#166 (comment)
30 remaining items
Kebap commentedon Dec 1, 2020
How can I use checkmarks inside spoiler? This is a checkmark:
Where
* [ ]starts an unchecked, and* [x]starts a checked line.However inside the spoiler, toggling state will collapse the spoiler..!
Open me and check three marks!
This is especially troublesome in longer spoilers than I showed above.
You will loose the scroll-state, and need to click much more than thrice.
Wohlstand commentedon Feb 8, 2021
When using the tag, pictures getting not working:
some
At Wiki this won't show, at issue comment here it works:

andreymal commentedon Feb 8, 2021
Just add a empty line after <details>/<summary>
Click me
pilyay commentedon Apr 28, 2021
Hello!
I want to make the name of the spoiler as a link, how do you think such an entry in markdown is correct?
glibg10b commentedon Jun 23, 2021
@pilyay
Chapter 1
Berchon commentedon Jul 4, 2021
I'm trying to do the same as @pilyay , but unfortunately your suggestion didn't work for me, @glibg10b .
glibg10b commentedon Jul 4, 2021
@Berchon maybe try a different browser? I think
<details/>'s implementation varies between browsers. I am using Firefox and it works fine.TWiStErRob commentedon Jul 4, 2021
@Berchon what does "doesn't work" mean in your case? I tried Android Chrome and it was hard to expand because we can't click on the link or the arrow, only on the right side of the line. After that it jumps to heading as expected. I guess adding more (unlinked) text would make this better. Note: the empty line after summary and before details is sometimes very important.
porg commentedon Oct 8, 2021
@ide and @TWiStErRob thanks for your practical solutions!
aniespica commentedon Aug 1, 2022
Am I having these problems any solution?
a-pav commentedon Jun 23, 2024
Is there any shortcut / autocomplete / button to spawn a
<detail>tag, ready to be filled in?I hate that every time I have to look it up or type it down!
vintagesucks commentedon Jun 26, 2024
@a-pav The Refined GitHub browser extension adds a button to do just that:
PieterjanDeClippel commentedon Jan 27, 2025
Works without any extension whatsoever:
Click to expand
Note that you need to leave an addtitional newline around the code block
Test using an image
Here's a gist
TWiStErRob commentedon Jan 27, 2025
@PieterjanDeClippel yes it does. The point in recent conversations is that a UI interaction is better than manual typing/Google-copy-paste, an interaction would ideally take care of annoyances like remembering to insert those new lines.
itsramiel commentedon May 14, 2025
Legend