
Hi all, I've just released the first version of the markdown package to Hackage[1]. I've been using this package for a while already for rendering blog posts on yesodweb.com. I put in some time today cleaning it up and fixing some features, and feel it's now ready for an experimental release. The distinguishing features of this library versus other options are: * Uses blaze-html types natively, making it easy to use with many existing libraries (Hamlet included). * Permissive license (BSD3). * attoparsec and conduit used for parsing. * Built in XSS protection (though you can disable it if desired). The library also has a very thorough test suite, but I'd be happy to accept more test cases. Please report issues/send pull requests on Github[2]. Michael [1] http://hackage.haskell.org/package/markdown [2] https://github.com/snoyberg/markdown

Hi Michael,
I've just released the first version of the markdown package to Hackage[1]. I've been using this package for a while already for rendering blog posts on yesodweb.com. I put in some time today cleaning it up and fixing some features, and feel it's now ready for an experimental release.
I'm looking for an replacement for pandoc to unlit Haskell code from README.markdow files (so that I can make sure that code examples from the README actually work). The pain with pandoc is, that it takes quite some time to build. This is especially an issue if you use travis-ci, as it delays failure reports about 5 minutes. In terms of build times, this package is already an improvement, but still not ideal. Cheers, Simon

On Sun, Jul 15, 2012 at 7:03 PM, Simon Hengel
Hi Michael,
I've just released the first version of the markdown package to Hackage[1]. I've been using this package for a while already for rendering blog posts on yesodweb.com. I put in some time today cleaning it up and fixing some features, and feel it's now ready for an experimental release.
I'm looking for an replacement for pandoc to unlit Haskell code from README.markdow files (so that I can make sure that code examples from the README actually work). The pain with pandoc is, that it takes quite some time to build. This is especially an issue if you use travis-ci, as it delays failure reports about 5 minutes.
In terms of build times, this package is already an improvement, but still not ideal.
Cheers, Simon
Hi Simon, One thing that has slowed build times significantly before is the `pack` function from `text`. Starting with 0.11.2, that's been improved drastically. I'm not sure if that's affecting you at all. But in general, I'm not trying to optimize for build times. I intend markdown to be another web library, and in then vein will allow it to depend on any library that I consider a "standard" web library. In this case, that includes some heavy hitters, like attoparsec. But for your purposes, I think the Text.Markdown.Block module itself (documentation hidden on Hackage, but have a look at the source) will probably provide you with the best API, and it only depends on `conduit`. It might be worth looking into building a tool based on that module alone. If that works for you, we can discuss different ways to make that available (compile time flags or a separate package seem like valid options). Michael

Hi Michael,
But for your purposes, I think the Text.Markdown.Block module itself (documentation hidden on Hackage, but have a look at the source) will probably provide you with the best API, and it only depends on `conduit`. It might be worth looking into building a tool based on that module alone.
I'll probably try jgm's suggestion first. Cheers, Simon

There are so many complexities in parsing markdown correctly that aren't obvious at first.
You may avoid this complexities, using Alex and Happy (example:
https://bitbucket.org/afiskon/hs-interpreter/src ).
2012/7/17 Simon Hengel
Hi Michael,
But for your purposes, I think the Text.Markdown.Block module itself (documentation hidden on Hackage, but have a look at the source) will probably provide you with the best API, and it only depends on `conduit`. It might be worth looking into building a tool based on that module alone.
I'll probably try jgm's suggestion first.
Cheers, Simon
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
-- С уважением, Александр Личный блог: http://eax.me/ Мой форум: http://it-talk.org/ Мой Twitter: http://twitter.com/afiskon

Michael, Have you tested this using the markdown test suite (and preferably also the PHP markdown test suite)? There are so many complexities in parsing markdown correctly that aren't obvious at first. (I say this from experience!) http://six.pairlist.net/pipermail/markdown-discuss/2007-May/000616.html http://www.mail-archive.com/markdown-discuss@six.pairlist.net/msg01542.html I can see from a few cursory tests that the library is FAR from being an accurate and complete markdown renderer. -------------- nested lists % ./markdown # <- a shell around Text.Markdown with default options 1. one 1. two - three <ol><li>one</li></ol><pre><code>1. two - three</code></pre> % Markdown.pl # <- original markdown perl script 1. one 1. two - three <ol> <li>one <ol><li>two <ul><li>three</li></ul></li></ol></li> </ol> -------------- inline code % ./markdown ``` `` ``` <p>``<code> </code>``</p> % Markdown.pl ``` `` ``` <p><code>``</code></p> -------------- reference-style links % ./markdown [Hi][] [Hi]: /url <p>[Hi][]</p><p>[Hi]: /url</p> % Markdown.pl [Hi][] [Hi]: /url <p><a href="/url">Hi</a></p> Some advice: If you want a fast, non-GPL markdown parser, use http://hackage.haskell.org/package/discount or http://hackage.haskell.org/package/sundown (which wraps the library used by github). John +++ Michael Snoyman [Jul 15 12 17:28 ]:
Hi all,
I've just released the first version of the markdown package to Hackage[1]. I've been using this package for a while already for rendering blog posts on yesodweb.com. I put in some time today cleaning it up and fixing some features, and feel it's now ready for an experimental release.
The distinguishing features of this library versus other options are:
* Uses blaze-html types natively, making it easy to use with many existing libraries (Hamlet included). * Permissive license (BSD3). * attoparsec and conduit used for parsing. * Built in XSS protection (though you can disable it if desired).
The library also has a very thorough test suite, but I'd be happy to accept more test cases. Please report issues/send pull requests on Github[2].
Michael
[1] http://hackage.haskell.org/package/markdown [2] https://github.com/snoyberg/markdown
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

Thank you for the link to the test suite! I thought I'd seen
references to it elsewhere, but didn't know where to find it. I've
already started making some changes based on it.
As for discount and sundown: I actually forgot to mention in my
"distinguishing features" that the markdown package is pure Haskell,
which makes it far simpler to get it working on Windows, and
simplifies to some extent uploading executables to a server. In
theory, markdown also has the potential to be a very fast renderer,
though I have neither benchmarked it nor optimized it yet.
On Tue, Jul 17, 2012 at 12:48 AM, John MacFarlane
Michael,
Have you tested this using the markdown test suite (and preferably also the PHP markdown test suite)? There are so many complexities in parsing markdown correctly that aren't obvious at first. (I say this from experience!)
http://six.pairlist.net/pipermail/markdown-discuss/2007-May/000616.html http://www.mail-archive.com/markdown-discuss@six.pairlist.net/msg01542.html
I can see from a few cursory tests that the library is FAR from being an accurate and complete markdown renderer.
-------------- nested lists
% ./markdown # <- a shell around Text.Markdown with default options 1. one 1. two - three <ol><li>one</li></ol><pre><code>1. two - three</code></pre>
% Markdown.pl # <- original markdown perl script 1. one 1. two - three <ol> <li>one <ol><li>two <ul><li>three</li></ul></li></ol></li> </ol>
-------------- inline code
% ./markdown ``` `` ``` <p>``<code> </code>``</p>
% Markdown.pl ``` `` ``` <p><code>``</code></p>
-------------- reference-style links
% ./markdown [Hi][]
[Hi]: /url <p>[Hi][]</p><p>[Hi]: /url</p>
% Markdown.pl [Hi][]
[Hi]: /url <p><a href="/url">Hi</a></p>
Some advice: If you want a fast, non-GPL markdown parser, use
http://hackage.haskell.org/package/discount
or
http://hackage.haskell.org/package/sundown
(which wraps the library used by github).
John
+++ Michael Snoyman [Jul 15 12 17:28 ]:
Hi all,
I've just released the first version of the markdown package to Hackage[1]. I've been using this package for a while already for rendering blog posts on yesodweb.com. I put in some time today cleaning it up and fixing some features, and feel it's now ready for an experimental release.
The distinguishing features of this library versus other options are:
* Uses blaze-html types natively, making it easy to use with many existing libraries (Hamlet included). * Permissive license (BSD3). * attoparsec and conduit used for parsing. * Built in XSS protection (though you can disable it if desired).
The library also has a very thorough test suite, but I'd be happy to accept more test cases. Please report issues/send pull requests on Github[2].
Michael
[1] http://hackage.haskell.org/package/markdown [2] https://github.com/snoyberg/markdown
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

At Tue, 17 Jul 2012 07:05:44 +0300, Michael Snoyman wrote:
As for discount and sundown: I actually forgot to mention in my "distinguishing features" that the markdown package is pure Haskell, which makes it far simpler to get it working on Windows, and simplifies to some extent uploading executables to a server. In theory, markdown also has the potential to be a very fast renderer, though I have neither benchmarked it nor optimized it yet.
I don't know about `discount', but the sundown library is very lightweight and with no dependencies, so I doubt you'll have problems building that anywhere. That also reminds me that I should update it with upstream :). Moreover, sundown is thoroughly battle tested (it runs GitHub). However, there are still advantage to the pure Haskell approach - the biggest one is that you're working with sane datatypes instead that with char*... -- Francesco * Often in error, never in doubt

@Francesco sorry for the duplicates!
However, there are still advantage to the pure Haskell approach - the biggest one is that you're working with sane datatypes instead that with char*...
Would it theoretically be possible to map the parse result to a proper Haskell AST? Say is there a proper AST on the C side? Cheers, Simon

At Tue, 17 Jul 2012 16:05:48 +0200, Simon Hengel wrote:
Would it theoretically be possible to map the parse result to a proper Haskell AST? Say is there a proper AST on the C side?
Yes, that would actually be possible and not too hard to do considering how sundown is designed - you can pass a set of pointers to functions to the markdown parser to produce the final result. I never thought about doing that, and if I have time I'll look at it (if somebody else wants to do it I'd be glad to help). -- Francesco * Often in error, never in doubt

I took a closer look at `markdown.h' and it is definitely doable, it shouldn't bee too much of an effort either. I plan to write two backends, one for the two `Html' types defined in `html' and `blaze-html'. Since I probably won't have much time in the near future, this might not happen soon, but it will eventually :). -- Francesco * Often in error, never in doubt

At Tue, 17 Jul 2012 18:23:22 +0200, Simon Hengel wrote:
Would those go into separate packages?
No, I need access to the markdown C internals and I don't want to expose them. I might expose a more Haskelly interface if people show interest in writing new backends. But then again, I'm very open to people just forking and writing the backends, so that's probably the easiest route. -- Francesco * Often in error, never in doubt

On Tue, Jul 17, 2012 at 05:37:12PM +0100, Francesco Mazzoli wrote:
At Tue, 17 Jul 2012 18:23:22 +0200, Simon Hengel wrote:
Would those go into separate packages?
No, I need access to the markdown C internals and I don't want to expose them. I might expose a more Haskelly interface if people show interest in writing new backends.
Do you intend to go directly to html/blaze-html, without having an AST that represents Markdown? Cheers, Simon

At Wed, 18 Jul 2012 11:25:32 +0200, Simon Hengel wrote:
Do you intend to go directly to html/blaze-html, without having an AST that represents Markdown?
That is what I intended with a "more Haskelly interface". I'll see what is more straightforward to do - if using the callback functions is easy enough I'll just use those in each backend. Again feel free to poke around and issue pull requests :). -- Francesco * Often in error, never in doubt
participants (5)
-
Alexandr Alexeev
-
Francesco Mazzoli
-
John MacFarlane
-
Michael Snoyman
-
Simon Hengel