AtomLinter / linter-spell-latex

Provider for Atom linter-spell package to enable LaTeX spell checking.
MIT License
8 stars 7 forks source link

Latex syntax is spell checked #27

Open OliverGavin opened 6 years ago

OliverGavin commented 6 years ago

image

Should these be showing as warnings? It would be better if it was only rendered text that was corrected.

Aerijo commented 6 years ago

That is related to the scoping provided by language-latex. Checking the scope at the marked points shows that it is only text.tex.latex and meta.group.braces.tex. Therefore, the solution is one (or more) of the following: 1) Disable spell checking between { and } 2) Add new rules to language-latex to specifically look for two pairs of braces after \setlength and give them new scopes, which can then be blacklisted. 3) Add new rules to language-latex that scope text of the form \d+(ex|pt|...) (or similar) to something (maybe a meta. scope), so that it will not interfere with syntax highlighting, but can be blacklisted.

Of these, the first is extremely bad. Normal text will often be between braces, and not checking this kind of defeats the purpose of a spell checker. The second is better, but seems far too specific; how does one find all the commands that take such values? It would be a poor solution to just monkey patch it as people use find and use new commands.

The third could work, though it may cause issues when people legitimately make a typo that happens to have this form (but this would be rare in practice). Restricting there to be no spaces between the number and the unit would reduce false positives. Allowing the spaces would make it closer to legitimate LaTeX syntax though, so this choice would be between fewer false positives vs more faithful scoping.

agrossfield commented 5 years ago

I'm wondering if anyone is still working on this issue, since it's pretty frustrating. It's not just stuff inside braces -- custom commands, math commands (e.g. \mathrm, \frac), citations (e.g. \cite{Foo-2019}), and references (\ref{f:repex}) are all triggering spelling warnings. I'm pretty close to just turning off the spellchecker, since the signal to noise is now approaching zero.

Without digging into the code I can't be sure, but I'd think some of these would be easy to fix. The math commands one should be easy: since the syntax highlighter knows it's a math environment, it should be pretty easy to turn off spell checking inside there. Similarly, things that are clearly labels (inside cite, ref, or label) should be ignored.

frederikfaye commented 5 years ago

I second @agrossfield request!

Is there any easy (maybe hacky) way to ignore every single expression of one of the forms

where x,y,z can be any expression that does not include a [] or {} pair? I think that would take care of >99% of all problems related to this issue, for me at least.

schneiderfelipe commented 4 years ago

This issue makes this package close to being unusable. I first thought this had to do with #25 but it in fact doesn't.

I believe the problem lies in the checkedScopes variable in linter-spell-latex/lib/main.js. Although things like text.tex.latex are set to true there (and things like meta.preamble.latex ae set to false), checking the scopes at something like \documentclass gives:

(Pure text gives only text.tex.latex.) So I believe the way linter-spell works is too permissive: a single true works. We need that a single false makes it ignore the thing.

JackSwett commented 3 years ago

Anybody come up with a decent solution?