patleeman / quill-markdown-shortcuts

Quill.js module that converts markdown to rich text formatting while typing.
https://patleeman.github.io/quill-markdown-shortcuts/
139 stars 49 forks source link

How to set precedence for nested markdown shortcuts? #33

Open amit1rrr opened 4 years ago

amit1rrr commented 4 years ago

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 commented 4 years ago

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.

philiprenich commented 4 years ago

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 commented 4 years ago

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!