Live data from Hacker News

Show HN: Fast and Extensible Parser for Markdown in PHP

parsedown.org

11–20 of 39 posts

Re: Show HN: Fast and Extensible Parser for Markdown in PHP

#11
post #2

I remember seeing this on /r/PHP, and one of the top comments there was about it using Regex instead of parsing it like a language. However, I also recall that it's thanks to using regex that it works so quickly. So I figured I'd get this argument out of the way before someone else brought it up.

Can you parse HTML with regex?

http://stackoverflow.com/a/1732454

Re: Show HN: Fast and Extensible Parser for Markdown in PHP

#14
post #13

I've worked with several markdown implementations and parsedown is my current choice due to my main constraint - speed. Great work and thanks for sharing.

If speed is your top priority you may also want to look at Sundown, which can be installed as a PHP extension and is likely faster since it's just C.

https://github.com/chobie/php-sundown

Re: Show HN: Fast and Extensible Parser for Markdown in PHP

#17
post #2

I remember seeing this on /r/PHP, and one of the top comments there was about it using Regex instead of parsing it like a language. However, I also recall that it's thanks to using regex that it works so quickly. So I figured I'd get this argument out of the way before someone else brought it up.

Well, the original markdown.pl heavily uses regexps.

From having tilted at this windmill a little myself, I think:

1. It's tricky enough to handle correctly all the under-specified corner cases of basic markdown -- not to mention the popular extensions to it. The cognitive load of doing it with complex regexps gets heavy, quickly.

2. I'm incredibly impressed with all the work that John MacFarlane has put into the problem, for example in [Pandoc] and [Cheapskate].

[Pandoc]: https://github.com/jgm/pandoc

[Cheapskate]: https://github.com/jgm/cheapskate

Re: Show HN: Fast and Extensible Parser for Markdown in PHP

#18
post #9
post #3

Parsedown is certainly very fast, but I wouldn't call it "extensible". CeBe's markdown parser is nearly as fast, but focusses on being very easy to extend, so it's trivial to add custom syntax elements, see https://github.com/cebe/markdown (CeBe's library is inspired by parsedown)

> Parsedown is certainly very fast, but I wouldn't call it "extensible". Parsedown is extensible and it already has been extended. There's a well working extension of Parsedown that adds support for Markdown Extra. It's called Parsedown Extra. It can be found at https://github.com/erusev/parsedown-extra

It is possible to extend, but extensible requires more. In this case, ParsedownExtra looks to directly extend the Parsedown class. This is fine for a single extension, but it discourages utilization of multiple independent extensions.

Re: Show HN: Fast and Extensible Parser for Markdown in PHP

#19
post #16

Different markdown editors seem to be in disagreement how to parse the following: https://gist.github.com/anonymous/810ae1f7d52bcfffa1ef If the second empty line marks the end of the list block, the indented html (code block) should preserve tags

Yeah it looks like my site fails at this - http://markdownshare.com/view/96996ce5-63bc-45ca-af49-ba18cb...

Re: Show HN: Fast and Extensible Parser for Markdown in PHP

#20
post #12

It's important to remember that most markdown implementations (including his one) cannot be used to provide a safe mechanism for authoring user generated content without opening a site up to XSS vulnerabilities, since markdown allows arbritrary HTML markup.

Easily solved by proper use of HTMLPurifier on the output.
Post reply on HN