-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of common prefix in vocabulary #726
Comments
I would do this in two steps. First, add an entry to
This will ensure that correct uses of these terms don't raise alerts in other places (such as your capitalization rule). Second, create a extends: substitution
message: "Use '%s' instead of '%s'."
ignorecase: true
level: error
swap:
- MyProduct(?! Community| Enterprise): MyProduct
- MyProduct Community: MyProduct Community
- MyProduct Enterprise: MyProduct Enterprise Here's an example that showcases both parts: |
Thanks for the answer. If I try this, though, the third line in my example (with Anyway, why is it not possible to achieve this in the vocabulary alone? |
In the next release (v3.0.4), this will work with just a vocabulary:
|
I just tried it and it seems to work properly. Thank you very much! |
Check for existing issues
Environment
Describe the bug / provide steps to reproduce it
Although a similar issue of non-deterministic behaviour has already been raised, this is more of a request for advice than an actual bug (at least given the current behaviour).
Let's assume the following:
accept.txt
vocabulary:.vale.ini
:test.md
document:When I run Vale, the output oscillates between this:
and this:
Basically, the second line has two possible corrections and the third line is never detected as wrong. As I understand, this happens because
MyProduct
is a common prefix and the result depends on what rule is triggered first.As a workaround, I put the
MyProduct
common prefix in a separate substitution rule and left only the two more specific lines in the vocabulary. This works, but of course it's not ideal, especially when this pattern is repeated many times and the overlapping elements expand over time. The other downside is that, since the term is not in the vocabulary, it has to be manually added as an exception to other rules (for example, a rule on capitalization of headings).No amount of tinkering, with regex's and other combinations, to try and put all the definitions in the dictionary would get me around this, and I suspect it's really by design. Even trying to put all the definitions in the substitution rule has the same "competing rule" behaviour, unless I use a hack like this, which works but gives a less useful message as it doesn't capture the prefix:
Is this the best I can do or am I missing any useful Vale features? Or perhaps am I seeing it the wrong way? How would you tackle this problem?
The text was updated successfully, but these errors were encountered: