amyreese / markdown-pp

Preprocessor for Markdown files to generate a table of contents and other documentation needs
MIT License
309 stars 68 forks source link

Wonky mangulation of header tags when creating <a> tags for !TOC #43

Open ssteinerx opened 7 years ago

ssteinerx commented 7 years ago

This file, test1.mdpp:

# test.mdpp -- **H1**

## Table of Contents below -- \<H2\>
!TOC

## Test H2 that includes "some things in quotes" ##
Moar text

Produces this:

# test2.mdpp -- **H1**

## Table of Contents below -- \<H2\>
1\.  [Test H2 that includes "some things in quotes" ##](#testh2thatincludes"somethingsinquotes"##)

<a name="testh2thatincludes"somethingsinquotes"##"></a>

## 1\. Test H2 that includes "some things in quotes" ##
Moar text

The header that has quoted text completely baffle the link creator and it puts together a name field that is strings of stuff with embedded double quotes and bare strings that shouldn't be valid even if they can accidentally be parsed. Who knows what evil lurks within the hearts of HTML parsers, really?

I didn't get any further than that in my current explorations because I'm really only after the !INCLUDE functionality, but some docs with warnings or smartening up the tag creator (with some edge-case bending tests) might be in order.

I don't have time to create a pull request now, I just wanted to record this before it got away.