Refactoring markdown_toc.py