ProseMirror / prosemirror-markdown

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

Extend `noOpenClose` #43

Closed rowanc1 closed 4 years ago

rowanc1 commented 4 years ago

When extending this library with other markdown-it extensions, I am having to extend the function noOpenClose(type) here: https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/from_markdown.js#L94

For example, in markdown-it-texmath the following blocks are needed:

type == 'math_inline' || type == 'math_inline_double' || type == 'math_block' || type == 'math_block_eqno'

I was wondering if it is worth passing an options into MarkdownParser that then goes to tokenHandlers, so that this can be done without forking the library?

Let me know if this would be wanted and I can put together a PR.

marijnh commented 4 years ago

This does indeed sound like it should be configurable. Would adding a property for this to the token description properties work? If so, a PR for that would definitely be welcome. (You could make it backwards-compatible by making the property default to true for known single-token entities like code block and inline code.)

rowanc1 commented 4 years ago

Oh, yeah adding a property to the token descriptor is much better.

Thoughts on the name of that option: code_block: {block: "code_block", noOpenClose: true},

Will put a PR together now.

marijnh commented 4 years ago

I'd prefer noCloseToken for the property name.

rowanc1 commented 4 years ago

I have updated the PR with the change, and added docs for this feature.

rowanc1 commented 4 years ago

Thanks for your help on this!

See #44

Released as prosemirror-markdown 1.5.0

🚀