metalsmith / excerpts

A Metalsmith plugin to extract an excerpt from HTML files.
MIT License
24 stars 26 forks source link

Fix reference-style links in first paragraph #7

Closed mattwidmann closed 10 years ago

mattwidmann commented 10 years ago

This fixes issue #5.

Instead of finding the first paragraph from the Markdown source, convert it to HTML and then find the first <p> tag using cheerio. Two new tests are also included to ensure reference-style links are converted to anchor tags correctly and to ensure that the excerpt is the first Markdown paragraph, not a code block.

Also, whitespace is now trimmed from excerpts before adding them to a file.

ianstormtaylor commented 10 years ago

at this point, i think we should assume the input is already .html files so we don't have to marked() them twice. people can just put the excerpt step after the conversion step, and ill do a major bump on this lib since it's a breaking change

mattwidmann commented 10 years ago

Yeah, I didn't feel it made much sense to run marked() twice, but couldn't think of a way to fix this issue while maintaining the same order of evaluation.

mattwidmann commented 10 years ago

Alright, I made that change. Might want to make sure the tests look right and do a sanity check.

ianstormtaylor commented 10 years ago

nice! added in 1.0.0 thanks a bunch for the nice PR