Clickable Table of Contents for Markdown – Ctags with Gedit

MarkDown is a very fast way to write text. You just mark headings with hash “#”. Empty line creates paragraph.
This tutorial shows how you can create a clickable table of contents of your MarkDown document – right inside your text editor. This makes it easier to edit long documents.

Use Tero’s Markdown Rules for Ctags

$ sudo apt-get install ctags
$ nano $HOME/.ctags
$ cat .ctags
--langdef=markdown
--langmap=markdown:.md.markdown.tmd
--regex-markdown=/^(# \S.*)/\1/h,h1/
--regex-markdown=/^\s*\/\/\s*(TODO.*$)/\1/h,todo/
--regex-markdown=/^(# \S.*)/\1/h,toc/
--regex-markdown=/^(## \S.*)/. . . . \1/h,toc/
--regex-markdown=/^(### \S.*)/. . . . . . . . \1/h,toc/
$ ctags --list-maps|grep -i markdown
markdown *.md *.markdown *.tmd

Install into Gedit

$ sudo apt-get -y install gedit gedit-source-code-browser-plugin

Open Gedit

  • Gedit: Edit: Preferences: Plugins: Source Code Browser: enable
  • Gedit: F9. Source code.
  • Gedit: Open: [any markdown document with hash ## headings – and name ending with “.md”]

Enjoy

You now have double-clickable table of contents for your MarkDown documents. And there is even a double-clickable list of TODOs.

Posted in Uncategorized | Tagged , , , , , , , | Comments Off on Clickable Table of Contents for Markdown – Ctags with Gedit

Comments are closed.