Replaced the TOC genration with an exact port of reddit's code.

Signed-off-by: Scott McClaugherty <gamefreak4321@gmail.com>
Applied bug fixes from snuownd and sync with snudown.

Signed-off-by: Scott McClaugherty <gamefreak4321@gmail.com>
Merge pull request #434 from gamefreak/more-wiki-fixes

Wiki/markdown fixes