errata-ai / vale

:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
https://vale.sh
MIT License
4.52k stars 155 forks source link

Comments in markdown trigger erroneous spelling error #882

Open rbdixon opened 3 months ago

rbdixon commented 3 months ago

Check for existing issues

Environment

Reproducible on:

Describe the bug / provide steps to reproduce it

With the default config:

MinAlertLevel = suggestion

[*]
BasedOnStyles = Vale

This test document:

on <!-- TODO --> a 
sonata

Triggers a spelling error:

$ ./vale test.md 

 test.md
 2:2  error  Did you really mean 'ona'?  Vale.Spelling 

✖ 1 error, 0 warnings and 0 suggestions in 1 file.

My expectation was no errors would be reported.

Remove the comment in the test document and no errors are reported.

The pattern seems to be that the non-comment characters on the first line, in this case on and a, will be flagged as a spelling error on their first usage after the comment. If you break the HTML comment, like this < !-- TODO -->, the unexpected behavior does not occur.

Another failing example is:

on <span/> a 
sonata

By setting BlockIgnores = (?s) (<!--.*?-->)|(<[^>]+\/>) will workaround this issue. This does not, however, explain the unusual behavior where a portion of a valid word is flagged as a spelling error based on the preceding line.

ccoVeille commented 3 months ago

Good catch. Wonderful workaround