fenced code blocks in comments are not ignored if they contain an unpaired backtick
lopopolo opened this issue · comments
Describe the bug
If a comment contains a fenced code block (one that starts with three backticks), that code block is usually ignored.
When the code block contains a single unpaired backtick, the block is spellchecked.
To Reproduce
Steps to reproduce the behaviour:
- A file containing:
// From `spec/core/symbol/inspect_spec.rb`:
//
// ```ruby
// symbols = {
// fred: ":fred",
// :fred? => ":fred?",
// :fred! => ":fred!",
// :$ruby => ":$ruby",
// :@ruby => ":@ruby",
// :@@ruby => ":@@ruby",
// :"$ruby!" => ":\"$ruby!\"",
// :"$ruby?" => ":\"$ruby?\"",
// :"@ruby!" => ":\"@ruby!\"",
// :"@ruby?" => ":\"@ruby?\"",
// :"@@ruby!" => ":\"@@ruby!\"",
// :"@@ruby?" => ":\"@@ruby?\"",
//
// :$-w => ":$-w",
// :"$-ww" => ":\"$-ww\"",
// :"$+" => ":$+",
// :"$~" => ":$~",
// :"$:" => ":$:",
// :"$?" => ":$?",
// :"$<" => ":$<",
// :"$_" => ":$_",
// :"$/" => ":$/",
// :"$'" => ":$'",
// :"$\"" => ":$\"",
// :"$$" => ":$$",
// :"$." => ":$.",
// :"$," => ":$,",
// :"$`" => ":$`",
// :"$!" => ":$!",
// :"$;" => ":$;",
// :"$\\" => ":$\\",
// :"$=" => ":$=",
// :"$*" => ":$*",
// :"$>" => ":$>",
// :"$&" => ":$&",
// :"$@" => ":$@",
// :"$1234" => ":$1234",
//
// :-@ => ":-@",
// :+@ => ":+@",
// :% => ":%",
// :& => ":&",
// :* => ":*",
// :** => ":**",
// :"/" => ":/", # lhs quoted for emacs happiness
// :< => ":<",
// :<= => ":<=",
// :<=> => ":<=>",
// :== => ":==",
// :=== => ":===",
// :=~ => ":=~",
// :> => ":>",
// :>= => ":>=",
// :>> => ":>>",
// :[] => ":[]",
// :[]= => ":[]=",
// :"\<\<" => ":\<\<",
// :^ => ":^",
// :"`" => ":`", # for emacs, and justice!
// :~ => ":~",
// :| => ":|",
//
// :"!" => [":\"!\"", ":!" ],
// :"!=" => [":\"!=\"", ":!="],
// :"!~" => [":\"!~\"", ":!~"],
// :"\$" => ":\"$\"", # for justice!
// :"&&" => ":\"&&\"",
// :"'" => ":\"\'\"",
// :"," => ":\",\"",
// :"." => ":\".\"",
// :".." => ":\"..\"",
// :"..." => ":\"...\"",
// :":" => ":\":\"",
// :"::" => ":\"::\"",
// :";" => ":\";\"",
// :"=" => ":\"=\"",
// :"=>" => ":\"=>\"",
// :"\?" => ":\"?\"", # rawr!
// :"@" => ":\"@\"",
// :"||" => ":\"||\"",
// :"|||" => ":\"|||\"",
// :"++" => ":\"++\"",
//
// :"\"" => ":\"\\\"\"",
// :"\"\"" => ":\"\\\"\\\"\"",
//
// :"9" => ":\"9\"",
// :"foo bar" => ":\"foo bar\"",
// :"*foo" => ":\"*foo\"",
// :"foo " => ":\"foo \"",
// :" foo" => ":\" foo\"",
// :" " => ":\" \"",
// }
// ```
- Run
cargo spellcheck edit
- Observe these spelling errors:
error: spellcheck(Hunspell)
--> /Users/lopopolo/dev/artichoke/artichoke/spinoso-symbol/src/inspect.rs:796
|
796 | :"/" => ":/", # lhs quoted for emacs happiness
| ^^^
(122/284) Apply this suggestion [y,n,q,a,d,j,e,?]?
laths
lbs
ohs
» ls
`lhs`
...
error: spellcheck(Hunspell)
--> /Users/lopopolo/dev/artichoke/artichoke/spinoso-symbol/src/inspect.rs:796
|
796 | :"/" => ":/", # lhs quoted for emacs happiness
| ^^^^^
(123/284) Apply this suggestion [y,n,q,a,d,j,e,?]?
emaciates
e macs
maces
macs
» Emacs
`emacs`
...
error: spellcheck(Hunspell)
--> /Users/lopopolo/dev/artichoke/artichoke/spinoso-symbol/src/inspect.rs:810
|
810 | :"`" => ":`", # for emacs, and justice!
| ^^^^^
(194/284) Apply this suggestion [y,n,q,a,d,j,e,?]?
emaciates
e macs
maces
macs
» Emacs
`emacs`
...
error: spellcheck(Hunspell)
--> /Users/lopopolo/dev/artichoke/artichoke/spinoso-symbol/src/inspect.rs:829
|
829 | :"\?" => ":\"?\"", # rawr!
| ^^^^
(249/284) Apply this suggestion [y,n,q,a,d,j,e,?]?
raw r
rawer
» raw
`rawr`
...
Expected behavior
Screenshots
Please complete the following information:
- System: macOS
- Obtained:
cargo install
- Version:
cargo-spellcheck 0.11.0
Additional context
Now that I've also filed #257, I'm not sure if these two issues are the same because the sample snippet includes empty lines in the fenced code block comment.