-
Notifications
You must be signed in to change notification settings - Fork 5
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
don't cut off text for addendum in mid-word #607
Conversation
Format Python code with psf/black push
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it needs a little more tests, I'm not sure I understand what textwrap
does to multi-line input, which text areas are likely to get often
width=input_width, | ||
max_lines=max_lines, | ||
replace_whitespace=False, | ||
placeholder=overflow_message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how this would interact with newlines in value
, which people are likely to add in text areas I think.https://docs.python.org/3/library/textwrap.html#textwrap.TextWrapper.replace_whitespace says that it'll "cause strange output", which makes me a little hesitant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't cause strange output in our usage, which ends up removing the line breaks after any get added.
We just use textwrap.wrap to figure out how many lines should fit, but we let the pdf renderer handle the actual soft line breaks in the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't removing all of the line breaks, we're just collapsing things where multiple appear in a row. Test overflow of 90, and input:
At least 10% of people
in this target audience do not know what this term means.
Therefore, you must avoid this term, explain this term, or link to an explanation.
Results in 3 lines of text, when there should only be 2, because there are still some \n
s inside the input text. Extra lines like that could cause things to get cut off in the PDF by pushing the last line below the height of the text box, right?
…low and safe_value handling of whitespace
Format Python code with psf/black push
Tricky to test this given different way that whitespace (particularly newlines) happen in-browser input fields vs in a docstring in the unit test file, but I think this is all correct now! This now also fixes some minor, undiscovered but long-standing bugs in the addendum code too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The only weird thing was that preserve_newlines
isn't really respected if max_lines
< 1, but that makes sense IMO, maybe worth documenting, but up to you.
I'm going to add some better documentation on the public documentation site |
Fix #243
Sample interactive test: