rhinoman / go-commonmark

CommonMark wrapper for Go
Other
33 stars 6 forks source link

Expose escape_html and escape_href as go functions #6

Closed rabidgremlin closed 9 years ago

rabidgremlin commented 9 years ago

It would be great if the _escapehtml and _escapehref functions in html.c could be exposed as go functions that accepted and returned strings.

The commonmark escaping is non-standard and a pain to implement :)

rhinoman commented 9 years ago

I suppose it would be possible to create wrappers for them. However, those don't appear to be functions exported from libcmark (they look like internal functions to me). Though, I'm a little curious, what would you use them for?

rabidgremlin commented 9 years ago

I'm creating a small package that processes the AST generated by libcmark so that you can create "pluggable" outputs (eg something other then HTML). My first one is an HTML generator that I'm testing against the spec to make sure everything works as expected. After that I'm targeting Latex, Docboc etc

Unfortunately the commonmark escape functions are non-standard in a few places so cannot be replicated without a good deal of hackery which I can avoid if I use the ones in libcmark.

rhinoman commented 9 years ago

On closer inspection, I realized those two functions are static (not easily wrappable), and I'd rather not start editing core libcmark files to work around that (it gives me more things I'd have to maintain in go-commonmark). However, the two functions just turn around and call houdini: https://github.com/vmg/houdini. Creating a Go wrapper for the houdini library is probably beyond the scope of go-commonmark. I'd recommend just bringing houdini into your project and wrapping the functions you need.

rabidgremlin commented 9 years ago

Fair enough. I agree you don't want to mess with the core libcmark. I'll see if I can wrap houdini myself. Thanks