tbroadley / spellchecker-cli

A command-line tool for spellchecking files.
MIT License
119 stars 16 forks source link

Gear emoji is seen as misspelt #87

Closed nicholaswilde closed 2 years ago

nicholaswilde commented 2 years ago

When using a gear emoji in a markdown file, spellchecker flags the emoji but should probably be skipped.

Steps to reproduce the issue

echo ":gear:" > test.md 
spellchecker test.md
Spellchecking 1 file...

test.md
  1:2-1:3  warning  `️` is misspelt; did you mean `a`, `b`, `c`, `d`, `e`, `f`, `g`, `h`, `i`, `j`, `k`, `l`, `m`, `n`, `o`, `p`, `q`, `r`, `s`, `t`, `u`, `v`, `w`, `x`, `y`, `z`?  retext-spell  retext-spell

⚠ 1 warning

Expected behavior

echo ":gear:" > test.md 
spellchecker test.md 
Spellchecking 1 file...

test.md: no issues found

spellchecker version: v4.11.0

uname -a
Linux amd 5.15.0-33-generic #34-Ubuntu SMP Wed May 18 13:34:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
tbroadley commented 2 years ago

Good catch. This might be as simple as upgrading the version of the remark-gemoji-to-emoji package that this project uses.

tbroadley commented 2 years ago

It looks like remark-gemoji-to-emoji hasn't been upgraded in a while. Seems like there's an equivalent package called remark-gemoji that's under @remarkjs, so that's promising.

I'm having difficulty using this package, though. I get type errors that I'm having trouble understanding. I think they might be related to using an old version of Remark. But I'm also stuck on upgrading Remark because Remark v14 moved from CommonJS modules to ES modules and I haven't yet figured out how to use the latter in this project.

nicholaswilde commented 2 years ago

Bah, it's the worst when relying on libraries that are out of date. I feel your pain. Thanks for looking into this so quickly 🙏🏽.

Do you happen to know how to bypass it for now by adding an entry to dictionary.txt?

tbroadley commented 2 years ago

If the tool is really failing on the empty string, I don't know if we can really catch that case with dictionary.txt.

Maybe a programmatic dictionary with an empty regex would work:

// dictionary.js
module.exports = [/^$/];

Another workaround would be to replace :gear: with a literal gear emoji character.

nicholaswilde commented 2 years ago

Using a literal ⚙️ worked, although not ideal. Thanks for the help.