diff --git a/se/commands/typogrify.py b/se/commands/typogrify.py index 402661f3..d1e7ab47 100644 --- a/se/commands/typogrify.py +++ b/se/commands/typogrify.py @@ -57,7 +57,12 @@ def typogrify(plain_output: bool) -> int: processed_xhtml = dom.to_string() else: - processed_xhtml = se.typography.typogrify(xhtml, args.quotes) + for node in dom.xpath("/html/body//img[@alt]"): + node.set_attr("alt", se.typography.typogrify(node.get_attr("alt"), args.quotes)) + + processed_xhtml = dom.to_string() + # Word joiners and nbsp don't belong in alt but that is handled by typogrify itself + processed_xhtml = se.typography.typogrify(processed_xhtml, args.quotes) # Tweak: Word joiners and nbsp don't go in the ToC if dom.xpath("/html/body//nav[contains(@epub:type, 'toc')]"): diff --git a/tests/draft_commands/typogrify/test-1/golden/typogrify.xhtml b/tests/draft_commands/typogrify/test-1/golden/typogrify.xhtml index 94dd6022..0d5fc89a 100644 --- a/tests/draft_commands/typogrify/test-1/golden/typogrify.xhtml +++ b/tests/draft_commands/typogrify/test-1/golden/typogrify.xhtml @@ -10,6 +10,7 @@

A Dreary Story

content of “chapter 1”

+ “Typography’s great …”—you can quote me on that.