r-lib / commonmark

High Performance CommonMark and Github Markdown Rendering in R
https://docs.ropensci.org/commonmark/
Other
88 stars 11 forks source link

Some sort of abstract representation? #4

Closed richfitz closed 8 years ago

richfitz commented 9 years ago

Motivated by a particular use I have, but presumably there's some sort of intermediate representation available in commonmark? Any chance of exposing that through R so that custom renderers can be written?

Thinking of something that could render markdown to marked up text using crayon in the terminal...

But perhaps I'm way off how this actually works under the hood.

jeroen commented 9 years ago

Yes internally it is just a syntax tree, and supposedly you can easily implement custom rendering formats in C. Although I think in practice it might be easier to get the syntax tree in xml format and go from there in R using xpath techniques and such.

richfitz commented 9 years ago

Fair enough, though I have an aversion to XML (and I see xml2 is off CRAN temporarily so I can't even try that - seriously WTF was that about?). R could do with a really nice tree data structure.

jeroen commented 8 years ago

I think going via xml is the best approach for reading and manipulating the syntax tree. Gabor has a nice package maxygen which uses commonmark + xml2 to support inline markdown for roxygen blocks. Closing this for now.