tbroadley / spellchecker-cli

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

Avoid regexes being surrounded with ^ & $ #42

Closed settermjd closed 4 years ago

settermjd commented 5 years ago

In the documentation, it says that any regexes are automatically surrounded with ^ & $. However, I need to use the following regex /(\[source,[a-z]+\])(\n\.{4}[\s\S]*?\.{4})/g, as it is, to match the two source blocks in the following AsciiDoc snippet.

Is this possible?

Limit access to push and tag events:

[source,console]
....
$ vault kv put secret/docker \
  username=octocat \
  password=correct-horse-battery-staple \
  x-drone-events=push,tag
....

You can combine annotations to limit by repository and event:

[source,console]
....
$ vault kv put secret/docker \
  username=octocat \
  password=correct-horse-battery-staple \
  x-drone-events=push,tag \
  x-drone-repos=octocat/*,spaceghost/*
....
tbroadley commented 5 years ago

Hey, thanks for the issue! I don't think it's possible to do this with spellchecker-cli, unfortunately. Dictionaries are intended to ignore single words, not longer blocks of text.

I think the correct solution would be to have special parsing for AsciiDoc files and ignore code blocks in them automatically.

xoxys commented 4 years ago

I have a similar issue with hugo flavored markdown files. I would like to exclude short codes e.g. {{.*}} to ignore short codes like {{< highlight Yaml "linenos=table" >}}.

For me it makes sense to only allow single words in a dictionary file but what about the ignore cli flag? Or could we simply add something like --ignore-raw flag?

tbroadley commented 4 years ago

Thanks for the report! OK, I think it might make sense to add some way to exclude larger chunks of text from files before spellchecking. First, how are you working around this issue currently? I'm guessing you've added the words you want to ignore to a dictionary file?

xoxys commented 4 years ago

Yes I have not found a better workaround and simply added the words to the dict. Ok for the Yaml example I currently use a simple regex like (Y|y)aml but yeah, actually not really what I want :)

xoxys commented 4 years ago

Another possible solution that comes to my mind are HTML comments, like markdownlint handles block excludes e.g.

<!-- spellchecker-disable -->
{{< highlight Shell "linenos=table" >}}
# some code
echo "Hello World"
{{< /highlight >}}
<!-- spellchecker-enable -->

See https://github.com/DavidAnson/markdownlint#configuration

tbroadley commented 4 years ago

I like the idea of using HTML comments to disable the spellchecker for certain parts of a Markdown file. I'd definitely accept a PR to add that functionality! I don't know if I'll get to implementing it myself. I might look into it this weekend if I have time.