Show & tell: remark-prosemirror #255
smoores-dev
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Thanks for sharing @smoores-dev! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@handlewithcare/remark-prosemirror
I just published the first release of remark-prosemirror! It contains a remark plugin to convert markdown into a ProseMirror document, and an mdast utility to convert a Prosemirror document into mdast.
Working with unified/syntax-tree made this so manageable. The big challenge was converting between ProseMirror marks (how ProseMirror models inline formatting, like bold and links) to mdast's nested phrasing content nodes. I ended up using the same algorithm the ProseMirror uses to map marks to HTML elements in the browser, which works well enough. It sometimes produces edge cases where adjacent formatted text nodes don't have their formatting combined, which results in a technically correct output that can be a little challenging for a human to read. 🤷 The cool thing about unified is that if someone really wanted to, they could add an mdast transformer that looks for that edge case and resolves it by modifying the tree!
Beta Was this translation helpful? Give feedback.
All reactions