frnmst/md-toc

Title with trailing spaces

Closed this issue · 1 comments

Hello again! Just noticed that when the last character of a title is an (admittedly useless) space, the generated anchor is wrong (tested on GitHub).

import md_toc

open("test.md", "w").write("""
# title
## title with a trailing space 
""")

print(md_toc.build_toc('test.md'))

Result:

- [title](#title)
  - [title with a trailing space ](#title-with-a-trailing-space-)

May be a .strip() somewhere would fix the issue?

HI,

I don't know / remember if this is a bug or not. At the moment md_toc uses the previous version of CommonMark spec (0.28 instead of 0.29). Maybe something changed. Have a look at:

If you find a solution, by all means open a pull request: