cspell-dicts icon indicating copy to clipboard operation
cspell-dicts copied to clipboard

fix Latex ignore patterns

Open Brandon-Johns opened this issue 1 week ago • 1 comments

Add/Fix Dictionary

Dictionary: Latex

Description

Fixes issues 627 and 754, which relate to the patterns applied to Latex by ignoreRegExpList. Inclues test cases.

The main focus in addressing 627 was to ensure that the start and end of math mode are correctly detected. If this fails, then the entire document could be ignored by the spellchecker by simply placing a commented dollar at the top.

In this, it was determined that detecting commented maths is not possible because the requirements for escaping do not apply. Comments with unescaped dollar chars are valid. Hence, LaTexMath has been changed to only apply to uncommented maths.

Only one test case remains still unfulfilled: Comments inside of math mode are not spellchecked. I concluded that it is not reasonably possible to catch this without a more comprihensive parser. Regex is just not powerfull enough.

Suggestion, but not changed

I would not include LaTexMath in ignoreRegExpList by default. Besides, spellcheching is still applied to the other maths environments:

\(maths\)
\[maths\]
\begin{equation}
    maths
\end{equation}
\begin{align}
    maths
\end{align}

References

  • https://github.com/streetsidesoftware/cspell-dicts/issues/627
  • https://github.com/streetsidesoftware/cspell-dicts/issues/754

Checklist

  • [x] By submitting this pull-request, you agree to follow our Code of Conduct
  • [x] Verify that the title starts with the correct prefix:
    • fix: - for minor changes like adding words or fixing spelling issues.
    • feat: - for a significant change like adding a whole new set of words to a dictionary.
    • feat!: - for breaking changes, like file format or licensing changes.
    • chore: - for changes that do not impact the content of dictionaries.

Brandon-Johns avatar Dec 16 '25 07:12 Brandon-Johns

@Brandon-Johns,

Wow, thank you.

After reading this, I might convert this to a .yaml file because all the escaping is difficult to mentally parse.

It might take me a day to two to test it out.

Jason3S avatar Dec 16 '25 17:12 Jason3S