Skip to main content

text: use Smartypants to handle the quote entities

ID
f5418eb
date
2026-04-11 20:12:47+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
d102b6f
message
text: use Smartypants to handle the quote entities
changed files
2 files, 4 additions, 3 deletions

Changed files

src/chives/text.py (713) → src/chives/text.py (721)

diff --git a/src/chives/text.py b/src/chives/text.py
index bc3617d..2ef2465 100644
--- a/src/chives/text.py
+++ b/src/chives/text.py
@@ -12,13 +12,13 @@ def smartify(text: str) -> str:
     """
     Add curly quotes and smart dashes to a string.
     """
-    # Undo some escaping from Mistune.
-    text = text.replace("&quot;", '"')
-
     attrs = (
         # normal quotes (" and ') to curly ones
         smartypants.Attr.q
         |
+        # quote entities (&quot;) to curly quotes
+        smartypants.Attr.w
+        |
         # typewriter dashes (--) to en-dashes and dashes (---) to em-dashes
         smartypants.Attr.D
         |

tests/stubs/smartypants.pyi (108) → tests/stubs/smartypants.pyi (119)

diff --git a/tests/stubs/smartypants.pyi b/tests/stubs/smartypants.pyi
index 273b48b..766b445 100644
--- a/tests/stubs/smartypants.pyi
+++ b/tests/stubs/smartypants.pyi
@@ -3,5 +3,6 @@ class Attr:
     D: int
     e: int
     u: int
+    w: int
 
 def smartypants(text: str, attrs: int) -> str: ...