-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
bugfix: boxes: Fix quote text rendering for xfails. #942
Conversation
tests/ui/test_ui_tools.py
Outdated
marks=pytest.mark.xfail(reason="rendered_bug")), | ||
("""<blockquote> | ||
<blockquote> | ||
<p>A<br/>B</p> |
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.
A quick test indicated the server actually generates a <br>
(not xml) and after both A and B too?
There are also extra newlines in each blockquote associated with ::before and ::after - I've not looked at this in a while but are we relying on those to be present for spacing purposes?
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.
There's a similar test just above this, that had <br/>
as well, so I didn't cross-check with the server.
Yes, I presume they are there because the quoting expects some text after the quote, hence the newline
?
64ea1e1
to
7881c44
Compare
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.
@zee-bit Thanks for tackling this - This looks like a great improvement already 👍 Our quoting is OK right now, but more complex quotes certainly need some work!
As you indicated, the next step is adding more test cases; these need not be xfails if you can fix them at the same time :)
Some areas that stand out:
- blank lines after multi-quotes, eg. no response to a quote and quoted again -> extra blank line per quote level
- text above the quoted text, which is much more common with the " said..." format we have now, for quote-level>=2
- handling "split" or multiple quotes in the same message; this is particularly evident with the simple quotes enabled by starting lines with '>', though this isn't used in auto-quoting
Some of that may be part of #402. More work on this would be great, but if not then we should likely add more test cases with xfails, or at least a tracking issue which could point to #402 or perhaps replace it.
7881c44
to
6220988
Compare
@neiljp PR has been updated keeping in mind your review above.
|
ERROR: Label "PR needs update" does not exist and was thus not removed from this pull request. |
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.
@zee-bit The refactor definitely improves the readability, though it does expose the broken links!
This is definitely an improvement over the previous situation and works for higher levels of quoting including text above it, but we still end up with some strange behavior and style corruption at level 3-4+?
This appears an improvement over the previous iteration, though I'm not sure precisely what you've changed - and the newline changes are somewhat unclear.
This doesn't seem to address #402 directly (mixing of quote styles), though given the improvement already I'm open to merging a simplified version and iterating, if we can clarify the open points.
tests/ui/test_ui_tools.py
Outdated
"D"), | ||
id="quoted level 3"), | ||
case("""<blockquote> | ||
<p>A<br>B</p> |
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.
Does the server send this over two lines?
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.
Ahh, yes. Sorry, forgot to change this!
("{} {} {} A\n\n" | ||
"{} {} B\n\n" | ||
"{} C\n\n" |
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.
Could you explain why the newlines are removed?
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.
blank lines after multi-quotes, eg. no response to a quote and quoted again -> extra blank line per quote level
This is for addressing the first point of your review above. I thought you wanted those extra newlines to be removed. This is the code that that is responsible for this change:
if(markup[-1] == '\n'
and isinstance(markup[-2], tuple)
and markup[-2][0] == 'msg_quote'
and isinstance(markup[-2][1], list)
and markup[-2][1][-1] == '\n'):
markup = markup[:-1]
I am segregating this change to a new commit, just In case you are not satisfied with this.
Are those extra newlines important?
tests/ui/test_ui_tools.py
Outdated
id="quoted level 2-1-2"), | ||
case("""<p><a href='https://chat.zulip.org/1'</a>czo</p> | ||
<blockquote> | ||
<p><a href='https://chat.zulip.org/2'</a>czo</p> |
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.
This applies to the original links too, but these are actually invalid links - how do these pass?
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.
I don't understand what do you mean by "invalid links". Are you pointing out the incorrect syntax used for a
tag or the invalid links in general?
zulipterminal/ui_tools/boxes.py
Outdated
# Remove extra newline from the end of blockquotes | ||
if(markup[-1] == '\n' | ||
and isinstance(markup[-2], tuple) | ||
and markup[-2][0] == 'msg_quote' | ||
and isinstance(markup[-2][1], list) | ||
and markup[-2][1][-1] == '\n'): | ||
markup = markup[:-1] |
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.
This looks rather messy. Can this be included in the quote handler? If so, would it be clearer there?
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.
This piece of code checks for extra newlines after quotes and removes them. But, I agree, this looks messy and complex, mainly due to the following reason:
- Our
soup2mark
function is recursive, hence it becomes difficult to check for unnecessary blank lines after quotes.
Currently, I am relying onmarkup
to check for any appended\n
at the end of each recursion-step, then comparing it with the previous element if it wasblockquote
and had a\n
at the end already. We then remove this extra newline from the end of markup.
Let me see if I can simplify this!
6220988
to
bb0f5d7
Compare
@zee-bit I've just merged the first two commits, and replied on the stream about this. |
This commit removes the extra newline that was getting rendered at the end of end of multiline quotes. Tests amended.
bb0f5d7
to
7444e33
Compare
As per my comment in the stream, let's take the remainder of this regarding improving the newline handling into a separate PR? I'm more convinced about the remaining commit now, but in any case there seem to be remaining issues, possibly related to the html returned by the server. |
The later commit from this PR, related to removing extra newlines from the end of quoted messages, is branched off to #1003, as requested. Further improvements will be pushed to that PR. Closing this now. |
No description provided.