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
514 stars 31 forks source link

Replace display equations via regex #63

Closed TzWeiz closed 2 years ago

TzWeiz commented 3 years ago

Hi,

I would like to remove display equations instead of having their content shown on the Overleaf Textarea.

A display equation such as

\begin{equation}
a=b+c
\end{equation}

will result in the Overleaf Textarea displaying it as "a=b+c".

I have attempted with the following regex expression:

/\\begin{equation}[^\0]*\\end{equation}/gm

by trying it at https://regex101.com which works on the above display equation. However, when employing this regex expression, I met with an issue with Overleaf Textarea as shown in the log

Pattern incorrect. Text length reduced by :/[^\S]+\\begin{equation}[^]*\\end{equation}[^\S]+/gm, (1)
If this is custom filter, remove or update it. If it is not a custom filter, try to fix it by overriding it.
If you don't know what to do, add the following filter: /[^\S]+\\begin{equation}[^]*\\end{equation}[^\S]+/gm with value: %%EMPTY%%

I think this will be helpful for most researchers working with equations.

Thank you.

robindijkhof commented 3 years ago

One of the requirements is that the number of lines should always be equal.

1: \begin{equation}
2: a=b+c
3: \end{equation}

Can't be replaced by

1:

The number of lines changes from 3 to 1.

1: 
2: 
3: 

Should be valid. However, I am not much of a regex expert so I cannot help you with that.