diff --git a/manual/edit.rst b/manual/edit.rst index d86cc88df3..da09912fda 100644 --- a/manual/edit.rst +++ b/manual/edit.rst @@ -678,6 +678,14 @@ common in your book and to run a simple search and replace on individual words. check tool. If you do not do this and continue to use the Spell check tool, you could lose the changes you have made in the editor. +.. note:: + To exclude an individual file from being spell checked when running the + spell check tool, you can add the following comment just under the first + opening tag in the file:: + + + + Adding new dictionaries ########################### diff --git a/src/calibre/ebooks/oeb/polish/spell.py b/src/calibre/ebooks/oeb/polish/spell.py index 1c25cb898e..78ced6471f 100644 --- a/src/calibre/ebooks/oeb/polish/spell.py +++ b/src/calibre/ebooks/oeb/polish/spell.py @@ -275,6 +275,14 @@ def get_checkable_file_names(container): return file_names, ncx_toc +def root_is_excluded_from_spell_check(root): + for child in root: + q = (getattr(child, 'text', '') or '').strip().lower() + if q == 'calibre-no-spell-check': + return True + return False + + def get_all_words(container, book_locale, get_word_count=False): words = defaultdict(list) words[None] = 0 @@ -283,6 +291,8 @@ def get_all_words(container, book_locale, get_word_count=False): if not container.exists(file_name): continue root = container.parsed(file_name) + if root_is_excluded_from_spell_check(root): + continue if file_name == container.opf_name: read_words_from_opf(root, words, file_name, book_locale) elif file_name == ncx_toc: