diff --git a/dactyl/common.py b/dactyl/common.py index 07db4c8..78997a5 100644 --- a/dactyl/common.py +++ b/dactyl/common.py @@ -23,6 +23,8 @@ logger.addHandler(logging.StreamHandler()) logger.propagate = False +PACKAGE_NAME = "dactyl" # Used for Jinja PackageLoader + PDF_USE_DEFAULT = "__DEFAULT_FILENAME__" NO_PDF = "__NO_PDF__" ES_USE_DEFAULT = "__ES_USE_DEFAULT__" diff --git a/dactyl/dactyl_build.py b/dactyl/dactyl_build.py index 125881c..d2f10f4 100755 --- a/dactyl/dactyl_build.py +++ b/dactyl/dactyl_build.py @@ -290,7 +290,7 @@ def setup_html_env(self): else: preferred_undefined = jinja2.ChainableUndefined - loaderset = [jinja2.PackageLoader(__name__)] + loaderset = [jinja2.PackageLoader(PACKAGE_NAME)] if "template_path" in self.config: loaderset.insert(0, jinja2.FileSystemLoader(self.config["template_path"])) env = jinja2.Environment(undefined=preferred_undefined, diff --git a/dactyl/dactyl_style_checker.py b/dactyl/dactyl_style_checker.py index c743d30..39e192d 100755 --- a/dactyl/dactyl_style_checker.py +++ b/dactyl/dactyl_style_checker.py @@ -108,12 +108,13 @@ def load_spellchecker(self): def load_words_from_file(self, fhandle): """ Read a file or file-like object line by line and add the words - from that file to the built-in dictionary. + from that file to the built-in dictionary. Lines starting with # are + treated as comments and ignored. """ new_words = [] for line in fhandle: word = line.strip().lower() - if word: + if word and word[0] != "#": new_words.append(word) if new_words: self.spell.word_frequency.load_words(new_words) @@ -171,6 +172,10 @@ def check_page(self, page, context): # let's strip any of those out. [div.unwrap() for div in page.soup.find_all(name="div")] + # Inlined SVG elements can't be formatted the same way, so remove them. + # They won't be spell-checked. + [svg.decompose() for svg in page.soup.find_all(name="svg")] + # Sometimes certain elements don't have whitespace between then, so # .get_text() will mash words together. Adding ". " makes them register # as separate sentences, which is probably more accurate for readability. diff --git a/dactyl/openapi.py b/dactyl/openapi.py index 0992a5e..5b78d59 100644 --- a/dactyl/openapi.py +++ b/dactyl/openapi.py @@ -81,12 +81,12 @@ def setup_jinja_env(self, template_path=None): """Sets up the environment used to inject OpenAPI data into Markdown templates""" if template_path is None: - loader = jinja2.PackageLoader(__name__) + loader = jinja2.PackageLoader(PACKAGE_NAME) else: logger.debug("OpenAPI spec: preferring templates from %s"%template_path) loader = jinja2.ChoiceLoader([ jinja2.FileSystemLoader(template_path), - jinja2.PackageLoader(__name__) + jinja2.PackageLoader(PACKAGE_NAME) ]) self.env = jinja2.Environment(loader=loader, extensions=['jinja2.ext.i18n']) self.env.lstrip_blocks = True diff --git a/dactyl/version.py b/dactyl/version.py index c41af0b..62ea085 100644 --- a/dactyl/version.py +++ b/dactyl/version.py @@ -1 +1 @@ -__version__ = '0.14.2' +__version__ = '0.14.3' diff --git a/releasenotes.md b/releasenotes.md index 0d6e22d..ea4688f 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -1,3 +1,11 @@ +# v0.14.3 Release Notes + +This release adds compatibility with Jinja 3.x and includes two minor improvements to the style checker: + +- No longer attempts to check inlined SVG elements. (This caused false reports of misspelled words when the SVG contained text elements without whitespace between them.) +- Spelling file can now contain comments starting with `#`. (Only lines _starting_ with `#` are treated as comments.) + + # v0.14.2 Release Notes This release fixes a couple bugs in the built-in templates when using virtual pages with a `prefix` value. It also changes to use the `prefix` value inherited at the page level so that individual pages can overwrite the value if necessary. (A 404 page, for example, might want to use a separate prefix since it may be used at different paths.)