Skip to content
Mottie created page: GitLab collapse markdown authored by Mottie's avatar Mottie
A userscript that collapses markdown headers
* This script makes all markdown headers clickable and toggles the view of all content between same level headers (e.g. between H2 headers).
* It works on readme, issues, markdown preview, & wiki pages. Pretty much everywhere on GitLab.
* Click on any header to toggle the view of the content below it.
* Use <kbd>Shift</kbd> + Click to toggle the view of *all* same level header content.
* When the content of a header is expanded, all sub-headers are also expanded.
* Links within the header are still clickable.
* Can be used along with the [[GitLab-collapse-in-comment]] userscript.
* Use the userscript addon to change these settings (see screenshot below):
* **"Set GitLab collapse markdown state"** to `collapsed` (`expanded` by default) which collapses all header content (except `h1`) initially.
* **"Set GitLab collapse markdown colors"** to an JSON array with six color values (accepts named, hex, rgb, hsl, etc). For example:
```js
// palette generated by http://tools.medialab.sciences-po.fr/iwanthue/
// (colorblind friendly; soft)
["#6778d0", "#ac9c3d", "#b94a73", "#56ae6c", "#9750a1", "#ba543d"]
```
These six colors apply to the H1 through H6 header arrows respectively.
* After changing either option, make sure to reload the page (<kbd>Shift</kbd> + <kbd>F5</kbd>) to have the updated setting take effect.
* Click [this link]() to install from GitLab, [GreasyFork]() or from [OpenUserJS]().
## Screenshot
![]()
![]()
## Example
* Use with userscript installed
* **Note**: <kbd>Shift</kbd> + clicking on an H2 header below will also collapse this example block.
> # Header 1
>
> * Inside header 1
>
> ## Header 2
>
> * Inside header 2
> * Inside header 2
>
> ### Header 3
>
> * Inside header 3
>
> ### Header 3
>
> * Inside header 3
>
> #### Header 4
>
> * Inside header 4
>
> ##### Header 5
>
> * Inside header 5
> * Inside header 5
>
> ##### Header 5
>
> * Inside header 5
>
> ###### Header 6
>
> * Inside header 6
>
> #### Header 4
>
> * Inside header 4
> * Inside header 4
>
> ### Header 3
>
> * Inside header 3
>
> ### Header 3
>
> * Inside header 3
>
> ## Header 2
>
> * Inside header 2
>
> ### Header 3
>
> #### Header 4
>
> * Inside header 4
> * Inside header 4
## Change Log
### Version 0.1.0 (5/24/2017)
* Initial commit.