From 3b1dd116b16a5b41d3940aee7aa6727ea1298cd3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 22 Oct 2018 02:35:05 +0200 Subject: [PATCH] m.htmlsanity: don't choke on links without refuri. Sorry :( --- pelican-plugins/m/htmlsanity.py | 2 +- pelican-plugins/m/test/htmlsanity_typography/page.html | 4 ++++ pelican-plugins/m/test/htmlsanity_typography/page.rst | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) 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 @@ Nest­ed con­tent should be hy­phen­at­ed al­so! And al&s ver­ba­tim stuff shouldn’t: hello "this" is not hyphenated. Nei­ther ver­ba­tim blocks:

"quote" hyphenation

Od­sta­vec v čeÅ¡­ti­ně. „Uvo­zov­ky“ fun­gu­jí ji­nak a dě­le­ní slov jakbys­met.

+ 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 -- 2.30.2