Some text
According to StackOverflow, this supposed to be comment in MarkDown:
[//]: # "some-text"
You put this text in your file where TOC should be:
[//]: # "start-toc"
[//]: # "end-toc"
So, script takes content before such comment, after it, and write TOC before them.
You could see RAW version of this file te see how this script works.
You could use mdtoc2, if your file contains non-ascii symbols. mdtoc2 will unescape these symbols.
Put gh-md-to to on of your PATH
directory.