chiark / gitweb /
m.htmlsanity: don't choke on links without refuri.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 22 Oct 2018 00:35:05 +0000 (02:35 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 22 Oct 2018 00:35:05 +0000 (02:35 +0200)
Sorry :(

pelican-plugins/m/htmlsanity.py
pelican-plugins/m/test/htmlsanity_typography/page.html
pelican-plugins/m/test/htmlsanity_typography/page.rst

index b6c3e68e972df8b7f4e19e6c5abab438450f14a9..59028a82a67bbe4d2e03706e8209ee2d5bff8a80 100644 (file)
@@ -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
index c92c4d9227b0875203d23c9e7d35dbed10ac2335..0736a62650f48642850fca625adb425391bddd14 100644 (file)
@@ -52,12 +52,16 @@ Nest&shy;ed con&shy;tent should be hy&shy;phen&shy;at&shy;ed al&shy;so! And al&s
 ver&shy;ba&shy;tim stuff shouldn’t: <span class="raw-html">hello "this" is not hyphenated</span>. Nei&shy;ther
 ver&shy;ba&shy;tim blocks:</p>
 "quote" hyphenation<p lang="cs">Od&shy;sta&shy;vec v češ&shy;ti&shy;ně. „Uvo&shy;zov&shy;ky“ fun&shy;gu&shy;jí ji&shy;nak a dě&shy;le&shy;ní slov jakbys&shy;met.</p>
+<section id="links">
+<h2>Links</h2>
 <p>Links with ti&shy;tles that are URLs (or e-mail ad&shy;dress&shy;es) shouldn’t be hy&shy;phen&shy;at&shy;ed
 ei&shy;ther:</p>
 <ul>
 <li><a href="mailto:info&#64;magnum.graphics">info&#64;magnum.graphics</a></li>
 <li><a href="https://magnum.graphics">https://magnum.graphics</a></li>
+<li><a href="#links">Links</a> with&shy;out re&shy;fu&shy;ri should not give an er&shy;ror</li>
 </ul>
+</section>
 <!-- /content -->
       </div>
     </div>
index cdab8f14960af95239b9de58f045eaf436848f72..3d7bf2040760bafb26e9b57784f3c415641ba526 100644 (file)
@@ -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