Hannah-Sten / TeXiFy-IDEA

LaTeX support for the IntelliJ platform by JetBrains.
https://hannah-sten.github.io/TeXiFy-IDEA
MIT License
893 stars 89 forks source link

repeated whitespace warning around mintinline when writing in Dutch. #3621

Open VVelthuizenHanze opened 3 months ago

VVelthuizenHanze commented 3 months ago

When writing in Dutch I get a repeated whitespace warning around mintinline command, suggesting the LanguageTool doesn't realize the body of mintinline will be part of the text.

I don't have this problem in English, is there a setting I can change to fix this? I don't want to disable proofreading all together.

MWE:

\documentclass[11pt]{article}

\usepackage[newfloat]{minted}

\begin{document}

Een uitleg van het \mintinline{java}{abstract} keyword in java.

\end{document}

The MWE shown in IntelliJ with the repeated whitespace error

PHPirates commented 2 months ago

Thanks for reporting this! The problem is also in English, see #3141, #3494 and #3508. Essentially, the problem is that somehow we need to tell Grazie that the rendered sentence reads "... van het abstract keyword in java..." and not "... van het java abstract keyword in java..." or "... van het keyword in java..." because that may lead to more false positive warnings in general (though probably not in this case). I do not yet know of a generic (approximate) way to tell if a word in a command will end up being typeset or not, as in the end we can only know this by typesetting the full document of course.

VVelthuizenHanze commented 2 months ago

It sounds to me like there needs to be a settings page for TeXiFy where commands can be added and specified how they work and that is pre-filled with common commands. (quickly reading through the mentioned issues I'm thinking at least check marks for: "produces output" and one for "produces surrounding white space".

Is this something I could help build? Or am I overstepping in even suggesting this (maybe you already have other ideas)?

PHPirates commented 2 months ago

Maybe. It makes sense for super special commands where you would only need to specify a few commands in settings, and this was suggested in https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/3492#issuecomment-2008960618 as well. However, for this we need information about all LaTeX commands, which is a bit too much.

If you want to help, that would be great! I think the first step is to solve this particular issue, that may be relatively easy and has to be done anyway. In the LatexTextExtractor class what we do is provide text ranges to ignore, so in the current implementation I guess we ignore just all commands. However, in your example, that means \mintinline{java}{abstract} is removed and we send Een uitleg van het keyword in java. Note the double space.

Instead, we could remove one of the spaces and send Een uitleg van het keyword in java. which happens to be grammatically correct. We could also just assume for now the first argument is the text, so we would send Een uitleg van het java keyword in java. which is grammatically correct. But then we still need to ignore commands like \usepackage, \begin, etc. Maybe we should just ignore all commands not in the middle of a sentence?

(text ranges are retrieved from the psi structure, which notably does not include spaces, but there are tricks to get around that)

VVelthuizenHanze commented 2 months ago

I look forward to diving into this. I have a deadline and a short vacation first. Thank you for pointing me in the right direction!