robindijkhof / overleaf-textarea

This plugin displays your tex source in a textarea so plugins like grammarly can check it.
GNU General Public License v3.0
509 stars 32 forks source link

Unbalanced matching of curly brackets #33

Open dsavchenko opened 3 years ago

dsavchenko commented 3 years ago

If the text in \caption{ } (other environments as well, but appears in captions frequently) contains the closing bracket "}", it is matched instead of the outer one, leading to the subsequent part of the text going to the textarea. BTW, what is the reason behind skipping captions?

robindijkhof commented 3 years ago

Hi, can you give a few examples? It is not clear to me what the problem is.

dsavchenko commented 3 years ago

Consider following latex \caption{The beginning $a=b_{22}$ and the rest of text}

Resultant plain text will be '$ and the rest of text' instead of either remove or include all the caption.

So the task is to match the outermost bracket of environment, skipping inner uses of them.

robindijkhof commented 3 years ago

Unfortunately, this is not something that can be easily done with a regex. Also, I'm not much of a regex expert.