caderek / gramma

command-line grammar checker
https://caderek.github.io/gramma/
ISC License
252 stars 18 forks source link

Ignore Specific Instances of a Finding #48

Open celestialorb opened 1 year ago

celestialorb commented 1 year ago

Is your feature request related to a problem? Please describe. I'd like to be able to instruct gramma to ignore a specific finding. I'm using Markdown with Pandoc and have some control sequences like \newpage which gets picked up as an issue by gramma/LanguageTool. These cases make using gramma difficult because on each run I have to tell it to ignore each and every one every time, or separate out files with these types of sequences.

Describe the solution you'd like I'd like to be able to instruct gramma to ignore specific findings by line (similar to most linters). I can see a few ways of accomplishing this.

The first would be to append a Markdown comment to the end of a line to instruct gramma to throw away the finding from the LanguageTool server:

\newpage <!-- gramma:ignore -->

Another method could be to surround a block of text to control whether or not gramma returns findings, similar to Python's Black formatter.

<!-- gramma:off -->
\newpage
<!-- gramma:on -->

Not sure how this would be accomplished outside of Markdown as the concept of a comment may not work everywhere else this is used.

For my specific case, perhaps a flag for LaTeX could be implemented (--latex); similar to the --markdown flag to remove these false positives.

Could also take an approach similar to the VSCode LanguageTool extension and save a database of manually marked false positives as I've done for this case:

{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"^\\Q\\newpage\\E$"}

Describe alternatives you've considered I can't think of any alternatives.