Skip to content

Commit

Permalink
typorify: Restore simplified version of nbsp before measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
acabal committed Nov 12, 2023
1 parent 2043147 commit e0be776
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions se/typography.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ def typogrify(xhtml: str, smart_quotes: bool = True) -> str:
xhtml = regex.sub(r"<p>\. …", "<p>…", 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)
Expand Down

0 comments on commit e0be776

Please sign in to comment.