The hyphenation is done using `Pyphen <http://pyphen.org/>`_ and is applied to
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:
+same goes for literal and raw blocks and links with URL (or e-mail) as a title.
+You can see it in practice in the following convoluted example, it's also
+language-aware:
.. code-figure::
# - raw code (such as SVG)
# - field names
# - bibliographic elements (author, date, ... fields)
+ # - links with title that's the same as URL (or e-mail)
if isinstance(txtnode.parent, nodes.literal) or \
isinstance(txtnode.parent.parent, nodes.literal) or \
isinstance(txtnode.parent, nodes.raw) or \
isinstance(txtnode.parent, nodes.field_name) or \
- isinstance(txtnode.parent, nodes.Bibliographic):
+ isinstance(txtnode.parent, nodes.Bibliographic) or \
+ (isinstance(txtnode.parent, nodes.reference) and
+ (txtnode.astext() == txtnode.parent['refuri'] or 'mailto:' + txtnode.astext() == txtnode.parent['refuri'])):
return False
# From fields include only the ones that are in FORMATTED_FIELDS
for txtnode in node.traverse(nodes.Text):
if not can_apply_typography(txtnode): continue
- # Don't hyphenate document title
+
+ # Don't hyphenate document title. Not part of
+ # can_apply_typography() because we *do* want smart quotes for
+ # a document title.
if isinstance(txtnode.parent, nodes.title): continue
# Useful for debugging, don't remove ;)
ver­ba­tim stuff shouldn’t: <span class="raw-html">hello "this" is not hyphenated</span>. Nei­ther
ver­ba­tim blocks:</p>
"quote" hyphenation<p lang="cs">Od­sta­vec v češ­ti­ně. „Uvo­zov­ky“ fun­gu­jí ji­nak a dě­le­ní slov jakbys­met.</p>
+<p>Links with ti­tles that are URLs (or e-mail ad­dress­es) shouldn’t be hy­phen­at­ed
+ei­ther:</p>
+<ul>
+<li><a href="mailto:info@magnum.graphics">info@magnum.graphics</a></li>
+<li><a href="https://magnum.graphics">https://magnum.graphics</a></li>
+</ul>
<!-- /content -->
</div>
</div>