tbroadley / spellchecker-cli

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

Spelling error line numbers are incorrect when using HTML entities (or maybe Markdown tables?) #102

Open austenstone opened 2 years ago

austenstone commented 2 years ago

The line numbers are incorrect when using HTML entitys such as  .

test.md

| github‑token | Token to use to authorize. | ${{ github.token }} |
| file‑json | JSON file containing the list of files to check. | ${{ file-json }} |
| files‑changed | List of files to check. | ${{ files-changed }} |
spellchecker test.md --reports test.json
test.json ```json [ { "data": {}, "messages": [ { "message": "`github‑token` is misspelt", "name": "test.md:1:3-1:15", "reason": "`github‑token` is misspelt", "line": 1, "column": 3, "location": { "start": { "line": 1, "column": 3, "offset": 2 }, "end": { "line": 1, "column": 15, "offset": 14 } }, "source": "retext-spell", "ruleId": "github-token", "file": "test.md", "fatal": false, "actual": "github‑token", "expected": [], "url": "https://github.com/retextjs/retext-spell#readme" }, { "message": "`file‑json` is misspelt", "name": "test.md:1:72-1:81", "reason": "`file‑json` is misspelt", "line": 1, "column": 72, "location": { "start": { "line": 1, "column": 72, "offset": 71 }, "end": { "line": 1, "column": 81, "offset": 80 } }, "source": "retext-spell", "ruleId": "file-json", "file": "test.md", "fatal": false, "actual": "file‑json", "expected": [], "url": "https://github.com/retextjs/retext-spell#readme" }, { "message": "`JSON` is misspelt; did you mean `JASON`, `JON`, `SON`?", "name": "test.md:1:84-2:2", "reason": "`JSON` is misspelt; did you mean `JASON`, `JON`, `SON`?", "line": 1, "column": 84, "location": { "start": { "line": 1, "column": 84, "offset": 83 }, "end": { "line": 2, "column": 2, "offset": 87 } }, "source": "retext-spell", "ruleId": "json", "file": "test.md", "fatal": false, "actual": "JSON", "expected": [ "JASON", "JON", "SON" ], "url": "https://github.com/retextjs/retext-spell#readme" }, { "message": "`file-json` is misspelt", "name": "test.md:2:53-2:62", "reason": "`file-json` is misspelt", "line": 2, "column": 53, "location": { "start": { "line": 2, "column": 53, "offset": 138 }, "end": { "line": 2, "column": 62, "offset": 147 } }, "source": "retext-spell", "ruleId": "file-json", "file": "test.md", "fatal": false, "actual": "file-json", "expected": [], "url": "https://github.com/retextjs/retext-spell#readme" } ], "history": [ "test.md" ], "cwd": "C:\\Users\\auste\\source\\spellchecker-cli-action-summary", "contents": "| github‑token | Token to use to authorize. | ${{ github.token }} |\r\n| file‑json | JSON file containing the list of files to check. | ${{ file-json }} |\r\n| files‑changed | List of files to check. | ${{ files-changed }} |", "value": "| github‑token | Token to use to authorize. | ${{ github.token }} |\r\n| file‑json | JSON file containing the list of files to check. | ${{ file-json }} |\r\n| files‑changed | List of files to check. | ${{ files-changed }} |\n" } ] ```
Result Word Line Start Line End Line Start Expected Line End Expected
github‑token 1 1 1 1
file‑json 1 1 2 2
JSON 1 2 2 2
file-json 2 2 2 2
tbroadley commented 2 years ago

Thank you for reporting this!

I won't have time to investigate this in the near future. Feel free to dig into it if you're interested.

I expect this is a problem with one of the libraries that Spellchecker CLI uses to spell-check Markdown files, namely remark, remark-retext, and retext-spell.