This python code will generate table of contents for your markdown file. Information on how to use it is in the README of the git repository.

Link to the Github repository