hellux / jotdown

A Djot parser library
MIT License
154 stars 11 forks source link

Provide C API #21

Open sorairolake opened 1 year ago

sorairolake commented 1 year ago

As far as I know, there is no C implementation of djot yet. So, I think it would be nice if there is C bindings of this library.

see also: https://github.com/eqrion/cbindgen

hellux commented 1 year ago

Yes, the thought has crossed my mind also. Question is, how should the API look like? The current API is quite Rust-focused and at least some manual work would be needed to make a reasonable C-API on top of it.

Exposing a function that converts djot directly to html would be simple, but djot to events and events to html would be a lot more useful.

I suppose it should be doable.

hellux commented 1 year ago

Actually, the lua reference implementation does have a minimal C API at https://github.com/jgm/djot.lua/tree/main/clib. It seems to expose direct rendering to HTML and json AST, and modification using lua filters.