Open colinodell opened 3 years ago
Just came across this issue and wanted to share, that I've written an extension that can convert an AST back to Markdown back in August 2021: https://github.com/stefanzweifel/commonmark-markdown-renderer
(I use this in a CLI to add release notes to CHANGELOG files with GitHub Actions.)
As you mentioned in https://github.com/thephpleague/commonmark/issues/419#issuecomment-835916625, such a renderer has quite a lot of edge cases. My package isn't perfect by any means. (Currently struggling to support multi-line list items for example)
419 and #511 require the ability to render the AST to Markdown. If we also add the ability to parse HTML into the AST then we could replace league/html-to-markdown with this package! Using an intermediate AST would also help with some of the issues/challenges in the other library.