From: Vladimír Vondruš
Date: Mon, 22 Oct 2018 00:35:05 +0000 (+0200)
Subject: m.htmlsanity: don't choke on links without refuri.
X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=3b1dd116b16a5b41d3940aee7aa6727ea1298cd3;p=blog.git
m.htmlsanity: don't choke on links without refuri.
Sorry :(
---
diff --git a/pelican-plugins/m/htmlsanity.py b/pelican-plugins/m/htmlsanity.py
index b6c3e68e..59028a82 100644
--- a/pelican-plugins/m/htmlsanity.py
+++ b/pelican-plugins/m/htmlsanity.py
@@ -85,7 +85,7 @@ def can_apply_typography(txtnode):
isinstance(txtnode.parent, nodes.field_name) or \
isinstance(txtnode.parent, nodes.Bibliographic) or \
(isinstance(txtnode.parent, nodes.reference) and
- (txtnode.astext() == txtnode.parent['refuri'] or 'mailto:' + txtnode.astext() == txtnode.parent['refuri'])):
+ (txtnode.astext() == txtnode.parent.get('refuri', '') or 'mailto:' + txtnode.astext() == txtnode.parent.get('refuri', ''))):
return False
# From fields include only the ones that are in FORMATTED_FIELDS
diff --git a/pelican-plugins/m/test/htmlsanity_typography/page.html b/pelican-plugins/m/test/htmlsanity_typography/page.html
index c92c4d92..0736a626 100644
--- a/pelican-plugins/m/test/htmlsanity_typography/page.html
+++ b/pelican-plugins/m/test/htmlsanity_typography/page.html
@@ -52,12 +52,16 @@ Nested content should be hyphenated also! And al&s
verbatim stuff shouldnât: hello "this" is not hyphenated. Neither
verbatim blocks:
"quote" hyphenationOdstavec v ÄeÅ¡tinÄ. âUvozovkyâ fungujà jinak a dÄlenà slov jakbysmet.
+
+Links
Links with titles that are URLs (or e-mail addresses) shouldnât be hyphenated
either:
+
diff --git a/pelican-plugins/m/test/htmlsanity_typography/page.rst b/pelican-plugins/m/test/htmlsanity_typography/page.rst
index cdab8f14..3d7bf204 100644
--- a/pelican-plugins/m/test/htmlsanity_typography/page.rst
+++ b/pelican-plugins/m/test/htmlsanity_typography/page.rst
@@ -34,8 +34,12 @@ verbatim blocks:
Odstavec v ÄeÅ¡tinÄ. "Uvozovky" fungujà jinak a dÄlenà slov jakbysmet.
+Links
+=====
+
Links with titles that are URLs (or e-mail addresses) shouldn't be hyphenated
either:
- info@magnum.graphics
- https://magnum.graphics
+- `Links`_ without refuri should not give an error