Skip to content

Commit

Permalink
Fix pyphen graceful degradation and en dictionary
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 2, 2016
1 parent 7245ff5 commit f98b90d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -11,6 +11,8 @@ Features
Bugfixes
--------

* Use ``en_US`` dictionary name with pyphen for better compatibility
* Fix graceful degradation if ``pyphen`` lacks dictionaries
* Add horizontal scrollbar to listings (via getnikola/nikola-themes#86)
* Copy files when importing two-file posts instead of reading and
writing (useful for binary formats, eg. docx) (Issue #2380)
Expand Down
2 changes: 1 addition & 1 deletion nikola/nikola.py
Expand Up @@ -289,7 +289,7 @@
'da': 'da',
'de': 'de',
'el': 'el',
'en': 'en',
'en': 'en_US',
'es': 'es',
'et': 'et',
'fr': 'fr',
Expand Down
2 changes: 2 additions & 0 deletions nikola/post.py
Expand Up @@ -1097,6 +1097,7 @@ def hyphenate(dom, _lang):
lang = LEGAL_VALUES['PYPHEN_LOCALES'].get(_lang, pyphen.language_fallback(_lang))
else:
utils.req_missing(['pyphen'], 'hyphenate texts', optional=True)
hyphenator = None
if pyphen is not None and lang is not None:
# If pyphen does exist, we tell the user when configuring the site.
# If it does not support a language, we ignore it quietly.
Expand All @@ -1105,6 +1106,7 @@ def hyphenate(dom, _lang):
except KeyError:
LOGGER.error("Cannot find hyphenation dictoniaries for {0} (from {1}).".format(lang, _lang))
LOGGER.error("Pyphen cannot be installed to ~/.local (pip install --user).")
if hyphenator is not None:
for tag in ('p', 'li', 'span'):
for node in dom.xpath("//%s[not(parent::pre)]" % tag):
skip_node = False
Expand Down

0 comments on commit f98b90d

Please sign in to comment.