commonmark / cmark

CommonMark parsing and rendering library and program in C
Other
1.62k stars 540 forks source link

Extension support in libcmark #100

Closed MathieuDuponchelle closed 8 years ago

MathieuDuponchelle commented 8 years ago

Hello, I always see "extensions" mentioned on discussions of features in CommonMark (for example the discussion about tables).

Does libcmark itself support actual extensions, and if so is there any guide on how to implement one, and an index of common extensions, or are extensions purely conceptual extensions to the specification, up to individual implementations to add ?

I'm pretty sure I could just read the code and find out but

Thanks for all your work on CommonMark / pandoc!

MathieuDuponchelle commented 8 years ago

ping :) I've now implemented the "gtk-doc" extension, mix of inline and block extensions, you can check out the code at https://github.com/hotdoc/hotdoc/blob/master/hotdoc/parsers/cmark_gtkdoc_extension.c . I think it shows the interface offered is pretty adequate, it allowed me to implement a pretty complex case, link_to_function() , where the parser has to perform a backward scan, and do some node merging / splitting in case of a match. See https://github.com/hotdoc/hotdoc/blob/master/hotdoc/parsers/tests/test_cmark_parser.py for some examples.

jgm commented 8 years ago

Sorry, I've had no time to look at this. I haven't forgotten about it, though.

MathieuDuponchelle commented 8 years ago

No worries, I know there's quite a lot of code in that diff, but that's also what makes me want to go ahead with this, I don't like resolving conflicts :) Fortunately we already merged the refactoring, which was bound to conflict a lot. By the way my branch is rebased on latest master, wasn't too difficult ^^

MathieuDuponchelle commented 8 years ago

Rebased again, make test still passes, please have a look at this :)

jgm commented 8 years ago

+++ Mathieu Duponchelle [Mar 25 16 06:00 ]:

Rebased again, make test still passes, please have a look at this :)

Sorry -- I've just got very minimal time right now, and this is going to take some time to evaluate. I will get to it in time.

MathieuDuponchelle commented 8 years ago

It would be great if we could at least review and cherry-pick some of the patches that expose new API etc, to reduce the conflict risk a bit ?

MathieuDuponchelle commented 8 years ago

Rebased again, some conflicts this time, make test still passes.

MathieuDuponchelle commented 8 years ago

Closing this issue, I've opened a pull request (linked above) and I think discussion should now happen there.