Skip to content

Commit

Permalink
fix: Use wcwidth to determine the monospace textual length of a string (
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic authored Oct 13, 2022
1 parent b523ed2 commit 908365f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pyyaml>=5.3.1
requests>=2.5.0
setuptools>=24.2.0
six>=1.4.1
wcwidth>=0.2.5
3 changes: 2 additions & 1 deletion xml2rfc/util/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
except ImportError:
pass

from wcwidth import wcswidth

unicode_content_tags = set([
'artwork',
Expand Down Expand Up @@ -197,7 +198,7 @@ def isascii(u):

def textwidth(u):
"Length of string, disregarding zero-width code points"
return len(re.sub('[\u200B\u200C\u2060\uE060]', '', u))
return wcswidth(u)

def downcode_punctuation(str):
while True:
Expand Down

0 comments on commit 908365f

Please sign in to comment.