-
Notifications
You must be signed in to change notification settings - Fork 29
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
widont line break/newline behavior #38
Comments
>>> re.match(r'\s', '\n')
<_sre.SRE_Match object; span=(0, 1), match='\n'>
>>> re.match(r'\s', r'\n')
>>> This result came as a surprise to me, but explains why widont has this behavior with newlines. But is this the desired behavior? That is, is the text passed in supposed to be escaped already? I believe this would be the easiest way to get the correct behavior in the above example: text = 'blah<br>\nblah'
text = text.encode('unicode-escape') # b'blah<br>\\nblah'
text = text.decode('utf-8') # 'blah<br>\\nblah'
text = widont(text) # 'blah<br>\\nblah'
text = text.encode('utf-8') # b'blah<br>\\nblah'
text = text.decode('unicode-escape') # 'blah<br>\nblah' It seems like it would be preferable for typogrify to deal with this, and I think it can be done without any encoding/decoding. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If a string ends with a
<br>
and a single word,widont
does nothing:This makes sense to me. But if a string ends with a
<br>\n
,widont
replaces the newline with a
:This doesn't seem right. While the first would render:
the second would render:
The text was updated successfully, but these errors were encountered: