This patch is best-viewed with --color-words.
Previously, references and notes right after setext or atx headers or html blocks were skipped over.
Previously the --smart option would trigger exponential slowdown in text heavy with intraword apostrophes. This fixes the problem. Str is now a bunch of NormalChars followed by a list of StrChunks. A StrChunk is either a bunch of NormalChars, an underscore followed by alphanumeric, or (in smart mode) an apostrophe.
Fletcher Penney pointed out the following bug in the previous version: ![figure] [figure]: fig.png "caption" width=75% is correctly *NOT* interpreted as a reference by most implementations due to the extraneous width attribute. Peg-markdown, however, strips the fig.png part, and leaves the "caption" and width as leftover text in the following paragraph: <p><img src="fig.png" alt="" /></p> <p>"caption" width=75%</p>
This way the following test case is parsed as by Markdown.pl: ============== <h1>## header text</h1> Thanks to Ali Rantakari.
Thanks to sirthias for both the bug report and the fix. sirthias notes: Rather than recursing into "HtmlBlockInTags" in each sub rule underneath "HtmlBlockInTags" the parser should recurse only in HTML blocks that have the same tag name as the enclosing tag. Recursion is only required to match corresponding pairs of opening/closing tags, not for rebuilding the HTML tag structure as such.