mkdocs_spellcheck ¤
MkDocs SpellCheck package.
A spell checker plugin for MkDocs.
Modules:
| Name | Description |
|---|---|
backends | Deprecated. Import directly from |
plugin | Deprecated. Import directly from |
words | Deprecated. Import directly from |
Classes:
| Name | Description |
|---|---|
Backend | Abstract class for spelling backends. |
CodespellBackend | Backend for the |
SpellCheckPlugin | A |
SymspellpyBackend | Backend for the |
Functions:
| Name | Description |
|---|---|
get_words | Get words in HTML text. |
load_backend | Load the specified backend. |
Backend(config: dict[str, Any], known_words: set[str] | None = None) ¤
Bases: ABC
Abstract class for spelling backends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | dict[str, Any] | User configuration from | required |
known_words | set[str] | None | Globally known words. | None |
Methods:
| Name | Description |
|---|---|
check | Check a word appearing in a page. |
Source code in src/mkdocs_spellcheck/_internal/backends/__init__.py
15 16 17 18 19 20 21 22 23 | |
check(page: Page, word: str) -> None abstractmethod ¤
Check a word appearing in a page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page | Page | The MkDocs page the word appears in. | required |
word | str | The word to check. | required |
Source code in src/mkdocs_spellcheck/_internal/backends/__init__.py
25 26 27 28 29 30 31 32 33 | |
CodespellBackend(config: dict[str, Any], known_words: set[str] | None = None) ¤
Bases: Backend
Backend for the codespell tool.
This backend needs to build a list of misspellings based on dictionaries provided by codespell itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | dict[str, Any] | User configuration from | required |
known_words | set[str] | None | Globally known words. | None |
Methods:
| Name | Description |
|---|---|
check | Check a word against the |
Attributes:
| Name | Type | Description |
|---|---|---|
misspellings | dict[str, Misspelling] | A mapping of misspelled words to their corrections. |
Source code in src/mkdocs_spellcheck/_internal/backends/codespell.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
misspellings: dict[str, Misspelling] = {} instance-attribute ¤
A mapping of misspelled words to their corrections.
check(page: Page, word: str) -> None ¤
Check a word against the codespell misspellings.
Source code in src/mkdocs_spellcheck/_internal/backends/codespell.py
75 76 77 78 79 80 | |
SpellCheckPlugin() ¤
Bases: BasePlugin[_SpellCheckConfig]
A mkdocs plugin.
This plugin defines the following event hooks:
on_configon_page_content
Check the Developing Plugins page of mkdocs for more information about its plugin system.
Methods:
| Name | Description |
|---|---|
on_config | Load words to ignore. |
on_page_content | Spell check everything. |
Attributes:
| Name | Type | Description |
|---|---|---|
allow_unicode | bool | Keep unicode characters. |
backends_config | list[str | dict[str, Any]] | Backend configuration. |
ignore_code | bool | Ignore words in code blocks. |
known_words | set[str] | Words to ignore. |
max_capital | int | Maximum number of capital letters in a word to consider it. |
min_length | int | Minimum word length. |
run | bool | Whether to run the plugin. |
skip_files | list[str] | Files to skip. |
strict_only | bool | Only run in strict mode. |
Source code in src/mkdocs_spellcheck/_internal/plugin.py
93 94 95 96 | |
allow_unicode: bool instance-attribute ¤
Keep unicode characters.
backends_config: list[str | dict[str, Any]] instance-attribute ¤
Backend configuration.
ignore_code: bool instance-attribute ¤
Ignore words in code blocks.
known_words: set[str] = set() instance-attribute ¤
Words to ignore.
max_capital: int instance-attribute ¤
Maximum number of capital letters in a word to consider it.
min_length: int instance-attribute ¤
Minimum word length.
run: bool instance-attribute ¤
Whether to run the plugin.
skip_files: list[str] instance-attribute ¤
Files to skip.
strict_only: bool instance-attribute ¤
Only run in strict mode.
on_config(config: MkDocsConfig) -> MkDocsConfig | None ¤
Load words to ignore.
Hook for the on_config event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | MkDocsConfig | The MkDocs config object. | required |
Returns:
| Type | Description |
|---|---|
MkDocsConfig | None | The modified config. |
Source code in src/mkdocs_spellcheck/_internal/plugin.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
on_page_content(html: str, page: Page, **kwargs: Any) -> None ¤
Spell check everything.
Hook for the on_page_content event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html | str | The HTML text. | required |
page | Page | The page instance. | required |
**kwargs | Any | Additional arguments passed by MkDocs. | {} |
Source code in src/mkdocs_spellcheck/_internal/plugin.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
SymspellpyBackend(config: dict[str, Any], known_words: set[str] | None = None) ¤
Bases: Backend
Backend for the symspellpy library.
This backend needs to load dictionaries provided by symspellpy itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | dict[str, Any] | User configuration from | required |
known_words | set[str] | None | Globally known words. | None |
Methods:
| Name | Description |
|---|---|
check | Check a word against the |
Attributes:
| Name | Type | Description |
|---|---|---|
spell | The |
Source code in src/mkdocs_spellcheck/_internal/backends/symspellpy.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
spell = SymSpell() instance-attribute ¤
The symspellpy spell checker.
check(page: Page, word: str) -> None ¤
Check a word against the symspellpy dictionary.
Source code in src/mkdocs_spellcheck/_internal/backends/symspellpy.py
61 62 63 64 65 66 67 68 69 70 71 | |
get_words(html: str, *, known_words: set[str] | None = None, min_length: int = 2, max_capital: int = 1, ignore_code: bool = True, allow_unicode: bool = True) -> list[str] ¤
Get words in HTML text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html | str | The HTML text. | required |
known_words | set[str] | None | Words to exclude. | None |
min_length | int | Words minimum length. | 2 |
max_capital | int | Maximum number of capital letters. | 1 |
ignore_code | bool | Ignore words in code tags. | True |
allow_unicode | bool | Keep unicode characters. | True |
Returns:
| Type | Description |
|---|---|
list[str] | A list of words. |
Source code in src/mkdocs_spellcheck/_internal/words.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
load_backend(name: str) -> type[Backend] ¤
Load the specified backend.
This function imports the specified backend and returns its class. It is important not to import the backends at the top level, as they may not be installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the backend to load. | required |
Returns:
| Type | Description |
|---|---|
type[Backend] | The backend class. |
Source code in src/mkdocs_spellcheck/_internal/plugin.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
backends ¤
Deprecated. Import directly from mkdocs_spellcheck instead.
Modules:
| Name | Description |
|---|---|
codespell | Deprecated. Import directly from |
symspellpy | Deprecated. Import directly from |
plugin ¤
Deprecated. Import directly from mkdocs_spellcheck instead.
words ¤
Deprecated. Import directly from mkdocs_spellcheck instead.