markdown-toc
markdown-toc copied to clipboard
Correctly detect frontmatter to avoid mangling document (fixes #180, fixes #189)
The previous format would incorrectly capture:
- A single horizontal rule at the top of the file
- Three literal dashes with arbitrary content after them. This was detected as a frontmatter, and an extra HR would be inserted after as a result.
The new format requires that there are two sets of triple dashes on their own lines, where the first is the first text in the document. This is necessarily the bounding box of a frontmatter, though the inner yml could be invalid and then would appear in the document instead.
There are still two more newline related issues I've noticed:
- An extra newline is inserted between the TOC and content on both top and bottom. This is fairly innocuous.
- ~~If the TOC is first or last item in the document, two spare newlines will be added on the contentless side every generation. Presumably caused by the section being empty but still in the section list.~~ Went ahead and fixed this too!