chiark / gitweb /
m.htmlsanity: apply hyphenation to everything in FORMATTED_FIELDS.
authorVladimír Vondruš <mosra@centrum.cz>
Tue, 7 Nov 2017 17:16:21 +0000 (18:16 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Tue, 7 Nov 2017 17:16:21 +0000 (18:16 +0100)
Instead of just the summary. Makes more sense.

doc/plugins/htmlsanity.rst
pelican-plugins/m/htmlsanity.py

index 26d269f1d6cc59011a850283c01b3a7c1f12019a..de4b6b6f2ba31b3250e13183a98b71d36e681649 100644 (file)
@@ -163,10 +163,10 @@ screens of mobile devices, where there is just way too much blank space because
 of long words being wrapped on new lines.
 
 The hyphenation is done using `Pyphen <http://pyphen.org/>`_ and is applied to
-whole document contents and article summaries (except for literal and raw
-blocks, of course). All other fields including document title are excluded from
-hyphenation. You can see it in practice in the following convoluted example,
-it's also language-aware:
+whole document contents and fields that are included in the :py:`FORMATTED_FIELDS`.
+All other fields including document title are excluded from hyphenation, the
+same goes for literal and raw blocks. You can see it in practice in the
+following convoluted example, it's also language-aware:
 
 .. code-figure::
 
index 3a2ca815d6972f4a9d22ce7b93f7172a6de2e165..69d7e043316e93c1c3532548380cac186d9ad016 100644 (file)
@@ -162,10 +162,11 @@ class Pyphen(Transform):
                    isinstance(txtnode.parent, nodes.raw):
                     continue
 
-                # From fields include only the summary
+                # From fields include only the ones that are in
+                # FORMATTED_FIELDS
                 if isinstance(txtnode.parent.parent, nodes.field_body):
                     field_name_index = txtnode.parent.parent.parent.first_child_matching_class(nodes.field_name)
-                    if txtnode.parent.parent.parent[field_name_index][0] != 'summary':
+                    if txtnode.parent.parent.parent[field_name_index][0] not in settings['FORMATTED_FIELDS']:
                         continue
 
                 # Useful for debugging, don't remove ;)
@@ -721,7 +722,7 @@ def configure_pelican(pelicanobj):
     global settings
     settings['M_HTMLSANITY_HYPHENATION'] = pelicanobj.settings.get('M_HTMLSANITY_HYPHENATION', False)
     settings['M_HTMLSANITY_SMART_QUOTES'] = pelicanobj.settings.get('M_HTMLSANITY_SMART_QUOTES', False)
-    for i in 'DEFAULT_LANG', 'DOCUTILS_SETTINGS', 'INTRASITE_LINK_REGEX', 'SITEURL':
+    for i in 'DEFAULT_LANG', 'DOCUTILS_SETTINGS', 'INTRASITE_LINK_REGEX', 'SITEURL', 'FORMATTED_FIELDS':
         settings[i] = pelicanobj.settings[i]
 
 def add_reader(readers):