[ANN] PEG Markdown Highlight

Ali Rantakari ali.markdown-discuss at hasseg.org
Wed Jun 29 12:31:21 EDT 2011

> How complex is the conversion?

The bulk of the grammar is the same but there are significant differences:

- All of the grammar actions are completely different (both in terms of content and where they are applied, or not applied)

- Angle brackets that delimit matched sections of interest within rules are applied differently because they determine the character offsets that will be accessible to the actions in the rule (as opposed to peg-markdown, where they delimit sections of "actual content" that the compiler wants to retain for translation purposes)

- In order to get the correct start offsets for most matches I apply the `s` identifier to the first subrule (and in cases where a rule begins with a literal, I add the `LocMarker` subrule to the beginning so that I have something to apply the identifier to). This was the simplest way that I found for getting the correct start offset of a matched rule that contains repeating subrules.

Section 5.1 in the report I wrote about the project discusses the necessary modifications on a more general level:


> Is it possible to create a script to modify his file to become your file?

It would be a useful thing to have for the reasons you provide, but I doubt it would be feasible. The effort of writing + maintaining such a script and manually fixing all the corner cases where it breaks would probably be significantly higher than the effort of manually applying changes from peg-markdown.

> This would be fantastic! It would be ridiculously easy to create a very simple app that did MD/MMD syntax highlighting and then processing to HTML or LaTeX or ODF(FODT) - at least on the Mac side.

That has been the plan. :) Right now I am not aware of any differences between peg-markdown's and this highlighter's input matching behavior (although I'm sure some exist) so if the app uses peg-markdown for output generation, then the syntax highlighting and the output should match.

More information about the Markdown-Discuss mailing list