Skip to content

Commit

Permalink
feat: Support Unix filename pattern matching when skipping files
Browse files Browse the repository at this point in the history
Issue-20: #20
PR-23: #23
  • Loading branch information
nfelt14 committed May 5, 2024
1 parent bd529b5 commit 2ae097d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ plugins:
# keep unicode characters
allow_unicode: no

# skip files entirely
# skip files entirely (supports Unix shell-style wildcards)
skip_files:
- credits.md
- coverage.md
- reference/*

# whether to only check in strict mode
strict_only: yes
Expand Down
5 changes: 4 additions & 1 deletion docs/known_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ dataclass
ahrens
dev
fr
uv
uv
codespell
mkdocs_spellcheck
symspellpy
3 changes: 2 additions & 1 deletion src/mkdocs_spellcheck/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

import fnmatch
from pathlib import Path
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -129,7 +130,7 @@ def on_page_content(self, html: str, page: Page, **kwargs: Any) -> None: # noqa
page: The page instance.
**kwargs: Additional arguments passed by MkDocs.
"""
if self.run and page.file.src_path not in self.skip_files:
if self.run and not any(fnmatch.fnmatch(page.file.src_path, pattern) for pattern in self.skip_files):
words = get_words(
html,
known_words=self.known_words,
Expand Down

0 comments on commit 2ae097d

Please sign in to comment.