Writing a custom renderer for the Editorjs block api #475
Unanswered
josegonzalez
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all! I've been working on a tool to allow me to edit markdown using editorjs. They have a block api that looks something like the following:
There's a decent number of supported block types - enough to span the markdown spec imo - and so my current task has been to try and convert markdown to the block api.
Currently I'm doing by walking the ast. The code for it is here. The general pattern is below:
Leaf and container markdown blocks convert basically immediately to the underlying spec, and anything inline just gets converted to html. That said, this breaks down with lists that have embedded fenced blocks, probably due to how I'm extracting the node element (code below). There are almost certainly other edge-cases it fails at too.
I think, therefore, that my method of parsing the markdown doc with goldmark is invalid, and was thinking that writing a real renderer might be better. Not sure how far off the mark I am with my method, but would someone be willing to walk me through a skeleton of what I'm trying to attempt?
Beta Was this translation helpful? Give feedback.
All reactions