commonmark icon indicating copy to clipboard operation
commonmark copied to clipboard

HTML to Markdown

Open colinodell opened this issue 2 years ago • 1 comments

#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.

colinodell avatar Sep 20 '21 13:09 colinodell

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)

stefanzweifel avatar Jul 29 '23 09:07 stefanzweifel