As noted here, some of the communities are using MathJax to render formulas. Anything between single or double dollar signs will be considered a formula ($...$ or $$...$$).
There would be concerns about false positives, like the ones @makyen mentioned here #181:
(e.g. someone providing a list of prices in $, would look like multiple blocks of $...$)
Short answer to this specific concern would be that in those communities, one needs to escape the dollar sign (\$) if they actually want to have it as is and not as indication of start/end of formulas.
Refer to to Match everything Between two Characters except when there is a Blank line for a detailed explanation of what should be considered a formula-block.
In the SO post above, The fourth bird's answer provides a regex that would match formula blocks and would not return false positives.
(?<!\S)(\$\$?+)[^\r\n$]*(?:\$(?!\$)[^\r\n$]*)*(?:\r?\n(?![^\S\r\n]*$)[^\r\n$]*(?:\$(?!\$)[^\r\n$]*)*)*\1(?!\S)
Regex101 demo
Wiktor Stribiżew's comment -- DEMO:
/^[^\S\r\n]*(\${1,2})(?:(?!\1|^$)[\s\S])+?\1[^\S\r\n]*$/gm
There is also a matter of implementing this only for communities which support MatchJax.
As noted here, some of the communities are using MathJax to render formulas. Anything between single or double dollar signs will be considered a formula (
$...$or$$...$$).There would be concerns about false positives, like the ones @makyen mentioned here #181:
Short answer to this specific concern would be that in those communities, one needs to escape the dollar sign (
\$) if they actually want to have it as is and not as indication of start/end of formulas.Refer to to Match everything Between two Characters except when there is a Blank line for a detailed explanation of what should be considered a formula-block.
In the SO post above, The fourth bird's answer provides a regex that would match formula blocks and would not return false positives.Regex101 demoWiktor Stribiżew's comment -- DEMO:
There is also a matter of implementing this only for communities which support MatchJax.