Fix issue #125 (formatting in TOCs) and out-of-bounds memory access in tab expansion

Again, many thanks from me and Google for your great Markdown library. Please let me know if there's anything amiss or anything I can help with.