chiark / gitweb /
m.htmlsanity: add dehyphenate filter and use it straight away.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 8 Sep 2017 09:35:44 +0000 (11:35 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Tue, 12 Sep 2017 10:06:26 +0000 (12:06 +0200)
pelican-plugins/m/htmlsanity.py
pelican-theme/templates/page.html

index 69605c63dba746065faa3393c13cd2fceee5fd2e..5eabf892afee2d73323e43e2cab4741635f74968 100644 (file)
@@ -471,9 +471,15 @@ def hyphenate(value, enable=None, lang=None):
     pyphen_ = pyphen.Pyphen(lang=lang)
     return words_re.sub(lambda m: pyphen_.inserted(m.group(0), '&shy;'), str(value))
 
+def dehyphenate(value, enable=None):
+    if enable is None: enable = enable_hyphenation
+    if not enable: return value
+    return value.replace('&shy;', '')
+
 def configure_pelican(pelicanobj):
     pelicanobj.settings['JINJA_FILTERS']['render_rst'] = render_rst
     pelicanobj.settings['JINJA_FILTERS']['hyphenate'] = hyphenate
+    pelicanobj.settings['JINJA_FILTERS']['dehyphenate'] = dehyphenate
 
     global enable_hyphenation, smart_quotes, hyphenation_lang, docutils_settings
     enable_hyphenation = pelicanobj.settings.get('HTMLSANITY_HYPHENATION', False)
index 00dde70f78d511e267fd7e94640ed20a3addaa3b..87000ff29b26852adbb44ef47a2d16bd122efb84 100644 (file)
@@ -1,4 +1,4 @@
-{% set page_title = page.title|replace('&shy;', '') %}
+{% set page_title = page.title|dehyphenate %}
 {% extends "base.html" %}
 
 {% block title %}{{ page.title }} | {{ SITENAME }}{% endblock %}