Escaping custom mark when entered as text

Hi, i’m using a custom schema and have added a custom mark to implement underline in markdown as it is a necessary requirement for this particular application. The mark is:

underline: { open: '!', close: '!', mixable: true, expelEnclosingWhitespace: true, escape: true }

I’ve also implemented a MarkdownIt plugin to help in parsing and tokenising the new mark which works fine.

The issue I’m having is that I need the use of ! in any inputted text to be escaped similar to * so it doesn’t trigger the new underline mark. I jumped to the conclusion that the escape prop in the MarkSerializerConfig would allow this to happen but quickly figured out that’s currently not the case. Does this escape prop work with custom marks?

And Is there a way to go about this?

Thanks :slight_smile:

The set of escaped characters in the Markdown serializer is currently hard-coded, but I suppose it would make sense to make that configurable. Want to create a pull request?

1 Like

Sure can do. :+1:

I have the same problem. I want to create a pull request, but current hard-coded characters in function is a bit more complex. ref: prosemirror-markdown/to_markdown.js at 13622eaa0f892c5a68a952f0950fd1a5d26c74ce · ProseMirror/prosemirror-markdown · GitHub

I think to add an option to MarkdownSerializerState to define extra characters to be escaped, what do you think?

I’d say that should be an option to MarkdownSerializer, but yeah, I’d still be interested in such a pull request.

1 Like