github/cmark-gfm

Support building for WebAssembly

Opened this issue · 0 comments

I was able to build cmark-gfm for WebAssembly. Here is the branch in my fork where I have been doing this development:

https://github.com/bolinfest/cmark-gfm/commits/wasm-demo

and here is a basic demo:

http://bolinfest.com/gfm/

To facilitate my own experimentation, I created a standalone build script:

https://github.com/bolinfest/cmark-gfm/blob/22d50cce547964d1762c7500990b3af4f6cb4954/web/build.py

Though this is mainly because I'm not proficient with CMake. I believe someone who knows what they are doing should be able to roll this into the existing build scripts without much difficulty as an optional build target. Of note:

  • src/emscripten_exports.cpp needs to be included as an input when building the WASM target
  • instead of clang, emcc should be used as the compiler
  • a number of extra flags have to be added: --bind, EXPORTED_FUNCTIONS=, EXTRA_EXPORTED_RUNTIME_METHODS=, etc. (note emcc supports @ for specifying a file of flags, though it has to be an absolute path)

Also, I believe my current build script is missing the GFM extensions, but I don't think they should be hard to add. I'll investigate that since I would like to play with them.

As far as the HTML test page is concerned, it could certainly be a lot nicer, but I did the bare minimum to make it straightforward to do ad-hoc testing of cmark-gfm. For sure, it would be helpful if it had some basic features of other playgrounds where the source of the input (and enabled options) gets added to the URL so you can share experiments easily. I think the next most important feature is to have options to show the output fo the various rendererers (man, LaTeX, etc.).

I am willing to help with the code, but I need to know whether the project is willing to add this support for WebAssembly in the first place or if I should continue to maintain this in my own fork.