Skip to content

Instantly share code, notes, and snippets.

@Ashton-W
Last active April 23, 2024 17:19
Show Gist options
  • Star 86 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save Ashton-W/864d09d71f7cb8e5b47ebaac02b98455 to your computer and use it in GitHub Desktop.
Save Ashton-W/864d09d71f7cb8e5b47ebaac02b98455 to your computer and use it in GitHub Desktop.
GitHub Markdown toggle code block
Click to toggle contents of `code`
CODE!
Click to toggle contents of other `code`
MORE CODE!
<details>
<summary>Click to toggle contents of `code`</summary>
```
CODE!
```
</details>
@Ashton-W
Copy link
Author

Ashton-W commented Jul 1, 2016

Learnt about it here https://gist.github.com/orta/057eab0832773aa299a6ebd39187ab06 but found out you can replace some of the HTML with a fenced code block :)

@abunsen
Copy link

abunsen commented Feb 21, 2018

Thank you!!

@soheon-lee
Copy link

Thanks!!

@nelantone
Copy link

Thank you! It works great 🎉 !

@Garllon
Copy link

Garllon commented Feb 12, 2021

This should work to highlight the code. You need the line breaks, before and after the block. Thanks to @Azure7111

Click to toggle contents of `code`
 Code

@sooendre
Copy link

Thank you!

@Piyush-linux
Copy link

Thank You :)

@YusufAbdelaziz
Copy link

Thanks :D

@maiconhenriquefa
Copy link

Thanks!

@kellyihyeon
Copy link

Thanks !

@joserojel-helix
Copy link

Code is not showing properly in Mac/Chrome.

@douglas-pires
Copy link

Try adding an extra space after <details>

For example:

{
    "some": "json"
}
function myFunction(): string {
  return "Hello!"
}

@imblurry
Copy link

Thank you so much!

@sasankaweera123
Copy link

Thank you this was very useful

Copy link

ghost commented Jan 21, 2023

thank you!!!!!

@per2jensen
Copy link

Thank you, very nice snippet :-)

@mhoffnn
Copy link

mhoffnn commented May 10, 2023

Nice :shipit:

@CharlyLegrandMartin
Copy link

Perfect! 🪄 Thanks!

@dhruvvyas25
Copy link

How to toggle with a second-level heading?

@emilienbidet
Copy link

Thanks

@zinzinzibidi
Copy link

Thanks!

@VoiceBeer
Copy link

thx :>

@SivaNagendraa
Copy link

Thank you

@usama-rahman
Copy link

thx

@stanley-ubidata
Copy link

Amazing! Thanks a lot!

@thesardorbroo
Copy link

thanks

@mustard-mh
Copy link

Thanks!!

@yippee0539
Copy link

yippee0539 commented Apr 20, 2024

This is a test
hello, world!

@horbjorn
Copy link

Thanks!

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