quill-markdown-shortcuts icon indicating copy to clipboard operation
quill-markdown-shortcuts copied to clipboard

How to set precedence for nested markdown shortcuts?

Open amit1rrr opened this issue 5 years ago • 3 comments

First of all, thank you @patleeman and all other contributors for an amazing Quill module. This was literally drop in for something that I considered would take me a week or more to support at ReviewNB.

One of the issues we are facing is how to set precedence when there are nested markdown shortcuts used? E.g. when people type [x for x in my_long_list_of_params] the underscores take precedence over backticks. This results in unintended formatting.

Is there configuration of some sort which would help us set precedence for markdown shortcuts?

amit1rrr avatar Jan 29 '20 06:01 amit1rrr

So the issue turned out to be broad regex for italics which I have modified in my fork.

The problem with the previous regex is that it captures any 2 underscores and converts the text between them to italics. e.g. my_local_var would convert local to italics. IMHO that is not how markdown intended it to be. The word should only become italics when starts and ends with underscore and there is no whitespace character immediately before or after the underscores.

Anyway my regex fixes the issue and is working fine for me.

I have created a PR here: https://github.com/patleeman/quill-markdown-shortcuts/pull/34

Hope someone can review this.

amit1rrr avatar Jan 29 '20 14:01 amit1rrr

I've left a comment on this.

Also, for reference, here are the docs on how to handle examples like my_local_var - use * for formatting, not _. That sounds like a different/more complicated regex :/

philiprenich avatar Feb 23 '20 00:02 philiprenich

ps @amit1rrr as someone who just found this module, I'm excited to see that there are people actively working to make it better! I'm hoping to start using it and contributing back as well if I find any issues!

philiprenich avatar Feb 23 '20 00:02 philiprenich