Skip to content

Instantly share code, notes, and snippets.

@gabrielboliveira
Created June 9, 2022 13:52
Show Gist options
  • Save gabrielboliveira/ac00aa84cec0a7ebc702066882886e64 to your computer and use it in GitHub Desktop.
Save gabrielboliveira/ac00aa84cec0a7ebc702066882886e64 to your computer and use it in GitHub Desktop.
Collapsible text in GitHub markdown

Collapsible text in GitHub markdown

A good suggestion to improve your texts in GitHub, either in Issues, PRs, README's or Wiki, is to use collapsible text. Example:

Expand me

https://c.tenor.com/AmA9IV_ssvIAAAAd/rick-rolled.gif

This is the Markdown code that generates the preview above:

<details>
<summary>This is the title</summary>
<p>

This is the content

</p>
</details>

Note: The two line breaks between the content is required, otherwise it won't properly generate it. Also, no tabulation.

Add this snippet to your vscode to easily expand this code:

	"Collapse text": {
		"prefix": "collapse",
		"body": [
			"<details>\n<summary>$1</summary>",
			"<p>\n\n$2\n\n</p>\n</details>",
		]
	}

Then, when writing Markdown in vscode, type collapse and expand.

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