From 4609309b73c60318766bf9336569068e4337f24f Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 13 Mar 2022 01:19:02 -0800 Subject: [PATCH] Add valid word characters as a configuration option See https://github.com/sphinx-contrib/spelling/issues/119#issuecomment-918367773 --- sphinxcontrib/spelling/__init__.py | 2 ++ sphinxcontrib/spelling/builder.py | 1 + sphinxcontrib/spelling/checker.py | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinxcontrib/spelling/__init__.py b/sphinxcontrib/spelling/__init__.py index 02b9362c..ed57141f 100644 --- a/sphinxcontrib/spelling/__init__.py +++ b/sphinxcontrib/spelling/__init__.py @@ -54,6 +54,8 @@ def setup(app): app.add_config_value('spelling_filters', [], 'env') # Set a user-provided list of files to ignore app.add_config_value('spelling_exclude_patterns', [], 'env') + # Set valid word characters + app.add_config_value('spelling_valid_word_characters', 'en_US', 'env') # Choose whether or not the misspelled output should be displayed # in the terminal app.add_config_value('spelling_verbose', True, 'env') diff --git a/sphinxcontrib/spelling/builder.py b/sphinxcontrib/spelling/builder.py index 55d7449c..0ac2ca38 100644 --- a/sphinxcontrib/spelling/builder.py +++ b/sphinxcontrib/spelling/builder.py @@ -86,6 +86,7 @@ def init(self): word_list_filename=word_list, filters=f, context_line=self.config.spelling_show_whole_line, + valid_word_chars=self.config.spelling_valid_word_characters, ) def _load_filter_classes(self, filters): diff --git a/sphinxcontrib/spelling/checker.py b/sphinxcontrib/spelling/checker.py index 6e56e5b8..e61b298c 100644 --- a/sphinxcontrib/spelling/checker.py +++ b/sphinxcontrib/spelling/checker.py @@ -21,7 +21,8 @@ class SpellingChecker: """ def __init__(self, lang, suggest, word_list_filename, - tokenizer_lang='en_US', filters=None, context_line=False): + tokenizer_lang='en_US', filters=None, context_line=False, + valid_word_chars=None): if enchant_import_error is not None: raise RuntimeError( 'Cannot instantiate SpellingChecker '