Reputation: 4951
I am using https://github.com/tbroadley/spellchecker-cli.
I have a JSON file that I'd like to run spellChecker on and it looks like this:
{
"abc.editGroupsMaxLengthError": "Maximum {{charLen}} characters"
}
I would like to know how can all words between {{
and }}
be ignored by the spellchecker.
I tried with
[A-Za-z]+}}
as documented here https://github.com/tbroadley/spellchecker-cli#ignore-regexes to ignore regex.
but it doesn't seem to use }}
or {{
for some reason.
How can this be fixed?
Upvotes: -1
Views: 398
Reputation: 627507
You can wrap your {{...}}
substrings with <!-- spellchecker-disable -->
/ <!-- spellchecker-enable -->
tags, see this Github issue.
So, make sure your JSON looks like
{
"abc.editGroupsMaxLengthError": "Maximum <!-- spellchecker-disable -->{{charLen}}<!-- spellchecker-enable --> characters"
}
And the result will be
C:\Users\admin\Documents\1>spellchecker spellchecker -f spellchecker_test.json
Spellchecking 1 file...
spellchecker_test.json: no issues found
To wrap the {{...}}
strings in a certain file in Windows you could use PowerShell, e.g., for a spellchecker_test.json
file:
powershell -Command "& {(Get-Content spellchecker_test.json -Raw) -replace '(?s){{.*?}}','<!-- spellchecker-disable -->$&<!-- spellchecker-enable -->' | Set-Content spellchecker_test.json}"
In *nix, Perl is preferable:
perl -0777 -i -pe 's/\{\{.*?}}/<!-- spellchecker-disable -->$&<!-- spellchecker-enable -->/s' spellchecker_test.json
Upvotes: 1