herald icon indicating copy to clipboard operation
herald copied to clipboard

use pegdown for markdown conversion

Open jrudolph opened this issue 12 years ago • 4 comments

I don't know if this is controversial but it seems that knockoff supports just a subset of the usual markdown syntax. For example, I'm always wondering which link syntax works and how to have monospaced text etc.

Here's a simple conversion to pegdown which supports a wider range of markdown syntax.

jrudolph avatar Jun 04 '12 15:06 jrudolph

What, is there a decent markdown parser for the jvm finally? :)

I guess the argument for knockoff is that it's all in Scala, and that's neat, but also we can extend it in Scala. I've done a bit of that for Pamflet, to add fenced code blocks, smart quotes and em-dashes. https://github.com/n8han/pamflet/tree/master/knockoff/src/main/scala

And that can be used by other projects, though I haven't integrated it with Herald yet. The best thing about the fenced code blocks is it's integrated with a javascript syntax highlighter, which I would be able to do for implicit.ly notes now that it's on tumblr.

What monospaced text format were you expecting, was it fenced code blocks?

I know about the links thing. It took me a while but I've internalized the format that tends to work with every markdown parser. Unfortunately, there is no standard for these things, just the original limited format defined by Gruber. :\

n8han avatar Jun 04 '12 16:06 n8han

As far as I checked it knockoff knows no syntax of the code blocks, no backquotes, no triple backquotes, and no fences.

IIRC pegdown already has most of those features out of the box. What it currently doesn't do is support code blocks with the language flag set. I guess that wouldn't be too hard to add to pegdown's parser if it is a requirement.

And you are right about the missing standard. That makes things painful because the language has already so many possible extensions. A written grammar would have turned up how many possible ambiguities the language contains and would have given rise to some modifications which would allow easier parsing.

jrudolph avatar Jun 07 '12 09:06 jrudolph

As far as I checked it knockoff knows no syntax of the code blocks, no backquotes, no triple backquotes, and no fences.

Right, that's why I added this support, in these sources I linked to before. :) https://github.com/n8han/pamflet/tree/master/knockoff/src/main/scala

n8han avatar Jun 07 '12 13:06 n8han

fwiw, we've been using Pegdown for the past 2 years or so in NetLogo and we've been completely pleased with it.

SethTisue avatar Jul 29 '12 23:07 SethTisue