crate-ci / typos

Source code spell checker
Apache License 2.0
2.33k stars 92 forks source link

Detect intraword emphasis in Markdown #755

Open not-my-profile opened 1 year ago

not-my-profile commented 1 year ago

It would be neat if typos could understand intraword emphasis in Markdown.

$ echo '`su` comes from **s**uper **u**ser.' > foo.md
$ typos foo.md
error: `uper` should be `super`, `upper`
  --> foo.md:1:22
  |
1 | `su` comes from **s**uper **u**ser.
  |                      ^^^^
  |
error: `ser` should be `set`
  --> foo.md:1:32
  |
1 | `su` comes from **s**uper **u**ser.
  |                                ^^^
  |
epage commented 1 year ago

This would require full knowledge of the languages involved to fix

Currently, our word extraction has no context like what the file type is. We do handle some common cases of syntax, but only in broad terms. For example, we ignore the word right after a \ because we don't know whether \tword is \t and word or \ and tword. Applying the same concept here, I'm not sure of a good rule of thumb that wouldn't cause us to miss checking a good swath of code.