Closed ssbarnea closed 4 months ago
You need to add comments to your Markdown documents, but Markdown has not comments. The proper search keywords would be Markdown
and comment
:
https://www.google.com/search?q=Markdown+comment
@DimitriPapadopoulos The first google link towards SO contains lots of comments that can be used in Markdown, being supported by most important libraries, but none is supported by codespell. I tried all from there before opening the issue.
Edit: the 1st sentence was wrong:
Wait, do you expect an isolated "codespell:ignore" to work by itself? You need "codespell:ignore word_to_ignore".
Otherwise, codespell does not need to support Markdown comments, it doesn't even parse Markdown as such — it just reads and interprets all files as a stream of text.
Finally, while Markdown doesn't have comments as such, the first Google link indeed explains how to abuse Markdown to add comments:
this is not a comment [//]: # ( this is a comment )
From there, just such a Markdown "comment" to add "codespell:ignore". For example:
$ cat file1.md
abandonned [//]: # ( )
$
$ codespell file1.md
file1.md:1: abandonned ==> abandoned
$
$ cat file2.md
abandonned [//]: # ( codespell:ignore abandonned )
$
$ codespell file2.md
$
Actually, it looks like Markdown does not have inline comments, they need to be on a line by themselves. For example,:
[//]: # ( this is a comment )
is not rendered, but
this is not a comment [//]: # ( this is a comment )
is rendered as:
this is not a comment [//]: # ( this is a comment )
Eventually, this is not a codespell issue. You need a way to add inline comments in a Makrdown file, but I don't think that's possible.
<!-- .. -->
is yet another way to add them.
Indeed, this:
this is not a comment <!-- this is a comment -->
appears to be rendered as:
this is not a comment
So you have your answer:
$ cat file1.md
abandonned <!-- -->
$
$ codespell file1.md
file1.md:1: abandonned ==> abandoned
$
$ cat file2.md
abandonned <!-- codespell:ignore -->
$
$ codespell file2.md
$
I tried to make use of inline ignore feature supposely introduced by https://github.com/codespell-project/codespell/pull/2400 inside Markdown documents but I found no way to do so.
A simple search on https://sourcegraph.com/search?q=context:global+lang:Markdown+codespell:ignore&patternType=keyword&sm=0 shows that nobody ever used the "codespell:ignore" inside a markdown document.