- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 173
 
GitHub collapse markdown
        Rob Garrison edited this page Oct 1, 2017 
        ·
        25 revisions
      
    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 & gist pages. Pretty much everywhere on GitHub.
 - Click on any header to toggle the view of the content below it.
 - Use Shift + 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 GitHub-table-of-contents & the GitHub-collapse-in-comment userscripts.
 - Use the userscript addon to change these settings (see screenshot below):
- 
"Set collapse markdown state" to
collapsed(expandedby default) which collapses all header content initially. - 
"Set collapse markdown colors" to an JSON array with six color values (accepts named, hex, rgb, hsl, etc). For example:
// palette generated by http://tools.medialab.sciences-po.fr/iwanthue/ // (colorblind friendly; soft) ["#6778d0", "#ac9c3d", "#b94a73", "#56ae6c", "#9750a1", "#ba543d"]
 
- After changing either option, make sure to reload the page (Shift + F5) to have the updated setting take effect.
 
 - 
 - Click this link to install from GitHub; or, install from GreasyFork or OpenUserJS.
 - Or, you can install it as a browser addon. Check out Octopatcher!
 


- Use with userscript installed
 - Note: Shift + clicking on an H2 header below will also collapse this example block.
 
- Inside header 1
 
- Inside header 2
 - Inside header 2
 
- Inside header 3
 
- Inside header 3
 
- Inside header 4
 
- Inside header 5
 - Inside header 5
 
- Inside header 5
 
- Inside header 6
 
- Inside header 4
 - Inside header 4
 
- Inside header 3
 
- Inside header 3
 
- Inside header 2
 
- Inside header 4
 - Inside header 4
 
- Code cleanup. Update to match Octopatcher code.
 
- Fix javascript error.
 
- Change license to MIT.
 
- Fix linting.
 
- Clean up "closest" function.
 - Use 
classListtoggle. 
- Make user set options case-insensitive
 
- Show current state when changing option.
 - Make code work on Firefox. Fixes issue #13.
 
- Change collapse markdown state choices to "collapsed" or "expanded".
 
- Beautify.
 
- Add support for GitHub-FixedHeader style.
 - Include GitHub help pages.
 - Fix lint & a code tweak.
 
- Don't toggle on link & image clicks.
 
- Initial commit.