From e0be776fd518e85415128e5b4c989182b0c215d6 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Sun, 12 Nov 2023 12:52:11 -0600 Subject: [PATCH] typorify: Restore simplified version of nbsp before measurements --- se/typography.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/se/typography.py b/se/typography.py index 82598cb3..c42f2c02 100644 --- a/se/typography.py +++ b/se/typography.py @@ -283,8 +283,8 @@ def typogrify(xhtml: str, smart_quotes: bool = True) -> str: xhtml = regex.sub(r"

\. …", "

…", xhtml) # Add non-breaking spaces between amounts with an abbreviated unit. E.g. 8 oz., 10 lbs. - # Removed because it's adding too many false positives - #xhtml = regex.sub(r"([0-9])\s+([\p{Letter}]{1,3}\.)", fr"\1{se.NO_BREAK_SPACE}\2", xhtml, flags=regex.IGNORECASE) + # Don't generalize this to match letters because it will add too many false positives + xhtml = regex.sub(r"([0-9])\s+(oz\.|lbs\.)", fr"\1{se.NO_BREAK_SPACE}\2", xhtml, flags=regex.IGNORECASE) # Add non-breaking spaces between Arabic numbers and AM/PM xhtml = regex.sub(r"([0-9])\s+([ap])\.m\.", fr"\1{se.NO_BREAK_SPACE}\2.m.", xhtml, flags=regex.IGNORECASE)