commonmark / cmark

CommonMark parsing and rendering library and program in C
Other
1.6k stars 527 forks source link

Super-WIP take terminal render for lowdown #529

Closed Ericson2314 closed 5 months ago

Ericson2314 commented 5 months ago

This doesn't work at all yet. It's just a sedded copy paste from https://github.com/kristapsdz/lowdown to close #362.

I'm just testing the waters here, per @jgm saying in https://github.com/commonmark/cmark/issues/362#issuecomment-1900820490 "I'd be open to it, but ...".

I will admit ~2000 lines more C for a more opinionated/open-ended feature (there is no way for a terminal rendering to be canonically correct, I would think) feels gross to me. (Maybe there are ways to deduplicate this with the rest of cmark, but I would not be confident in that. The rest of lowdown is vaguely similar and this wasn't deduplicated with that either.)

jgm commented 5 months ago

2000 lines more C for a more opinionated/open-ended feature (there is no way for a terminal rendering to be canonically correct, I would think) feels gross to me.

I'm inclined to agree with this. It's good to keep this library lean. Perhaps, for your purposes, you could develop this as a separate library, and then link it with cmark in your finished product.

Ericson2314 commented 5 months ago

Do you think there will be enough accessors functions to get out all the node-type-specific node info from the union?

jgm commented 5 months ago

Do you think there will be enough accessors functions to get out all the node-type-specific node info from the union?

You tell me. I believe the API exposes full information about the AST, but if something is missing, let us know.

Ericson2314 commented 5 months ago

Great; knowing that it's at least supposed to expose enough stuff to support a downstream renderer --- and thus any gaps can be filled --- is good :).