Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wcwidth to determine the monospace textual length of a string #914

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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