miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
836 stars 119 forks source link

Add rendering support for Atlassian Document Format #230

Open danarth opened 2 weeks ago

danarth commented 2 weeks ago

It would be really great to be able to parse Markdown and output a JSON document as Atlassian Document Format.

Mistletoe already supports rendering Jira syntax, but ADF is supported in both Jira and Confluence so would be incredibly useful for writing Confluence pages as Markdown.

I guess it could work similarly to the ASTRenderer works, since the BaseRenderer methods all expect string outputs, whereas this output is a JSON format so could make more sense to keep the responses as dictionaries and convert to a string at the very end.. but keen to hear thoughts.

I'd like to take a crack at this - my time is limited so may take a while :)

pbodnar commented 1 week ago

Hi @danarth, interesting, I haven't heard of this ADF, JSON-based format yet - probably because it is used just for the cloud, not for the "legacy" on-premise Jira/Confluence instances I'm used to work it.

Anyway, I agree a new renderer for ADF should probably basically work similarly to the existing AstRenderer. It has got this universal get_ast(token) method returning a dictionary. For ADF, this will get more complex, because we need to output specific attributes for each token type, e.g. for table.

Another possible "challenge" could be if for some token types the resulting hierarchy/tree wouldn't exactly match the mistletoe's AST...

I'd like to take a crack at this - my time is limited so may take a while :)

It would be great if you could take a closer look at this. Luckily, I hope, there is no rush. :)

pbodnar commented 1 week ago

PS: I suggest to place the new renderer to the contrib folder.