[ANN] PEG Markdown Highlight
bodhi at 5263.org
Wed Jun 29 04:13:58 EDT 2011
> the AST generated in phase 1 retains all positional information about the underlying markdown source
Hot damn! I asked about this about a year ago on this list when I was writing my Cocoa Markdown editor, but I couldn't get this info out of any of the C-based libraries easily. So my app ended up as a big hairy ball of regular expressions.
: http://keshiki.net/markdown-editor (slightly outdated)
On 29/06/2011, at 6:03 PM, Mathias wrote:
> Related to this:
> For some time now there is a [markdown plugin] for the IntelliJ IDEA IDE and all derived ones (RubyMine, PhpStorm, etc). that does exactly what Ali is describing: syntax-highlighting based on the parser of an actual markdown processor, which in this case is [pegdown], that started off as a java port of John MacFarlane's peg-markdown.
> The way this works:
> pegdown does its markdown-to-HTML in two phases:
> 1. parsing of the markdown source into an Abstract Syntax Tree
> 2. serialization of the AST to HTML
> Since the AST generated in phase 1 retains all positional information about the underlying markdown source it's very easy to syntax-highlight the editor buffer based solely on this AST (which is exactly what the plugin is doing).
> So if anyone is looking for a markdown syntax-highlighting solution for the JVM pegdown is probably something to look at.
> For C-based applications the peg-markdown-highlight by Ali is certainly the better choice...
> : https://github.com/nicoulaj/idea-markdown
> : http://www.pegdown.org
> mathias at parboiled.org
> On 28.06.2011, at 20:51, Ali Rantakari wrote:
>> Dear fellow Markdown enthusiasts,
>> As you all might know, Markdown is a highly context sensitive language that the (often regex-based) syntax highlighting mechanisms in existing editors struggle to keep up with.
>> I have taken John MacFarlane's excellent peg-markdown compiler and modified its parser to function as an interpreter for syntax highlighting purposes. The end result is a Markdown-specific syntax highlighter that should be able to match Markdown documents just as correctly as peg-markdown can, and that can easily be integrated into existing and new programs.
>> You can find all the relevant information at the project web page:
>> - Ali Rantakari
>> Markdown-Discuss mailing list
>> Markdown-Discuss at six.pairlist.net
> Markdown-Discuss mailing list
> Markdown-Discuss at six.pairlist.net
More information about the Markdown-Discuss