ProseMirror / prosemirror-markdown

ProseMirror Markdown integration
https://prosemirror.net
MIT License
345 stars 81 forks source link

Extended "type" spec to allow for functions #12

Closed bloff closed 7 years ago

bloff commented 7 years ago

This change allows for the Markdown parsing spec to determine the node by a function, instead of just by a string. This allows for parsing markdown nodes into different prosemirror nodes.

I needed this because I am using prosemirror with certain custom nodes (bibliographic references, in this case, and more in the future), and I need to be able to output a custom node depending on what I see in the markdown. E.g. a link [some bibliography text](bib: bibliographic-name) will be parsed as a special bibliographic reference node.

Nothing is lost compared to the old functionality, and I think it might be useful for others, as well.

marijnh commented 7 years ago

Sorry for letting this sit for so long. In the meantime, attrs seems to have lost this feature (being able to be a function), and the package uses getAttrs for computed attributes instead. Also, your pr is using tok in contexts where it doesn't exist yet. I'm going to close this, but if you still need it, feel free to open an issue.