-
-
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
Markup markdown text in stream description #749
Conversation
01ac899
to
5d88ccd
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.
@preetmishra Left some thoughts on the first commit here.
5d88ccd
to
f1b3de2
Compare
@sumanthvrao Thanks for the review. I have amended the tests and made the suggested amendments in the latest update. |
f1b3de2
to
0deaca8
Compare
0deaca8
to
6eacfa6
Compare
Updated to resolve conflicts. |
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.
@preetmishra This appears to work pretty well 👍
I'm not sure how busy you are at the moment to do any final work on this; my inline points should be fairly minor though we did just migrate the popup tests which has led to the conflict in test_ui_tools.py
.
Is the first commit just a refactor? (if large - I'm not sure how easy it'd be to split it?)
Maybe originally I thought this was just an exploratory PR and put off reviewing it, and perhaps wondered if you planned to move the adjusted methods into a separate file for processing rendered content? It is effective as it stands, and we can always make the latter migration later - it should be much easier with the decoupling changes you'll have made here 👍
90c68a2
to
0671ead
Compare
@neiljp Thanks for the review. I have resolved the conflict and made the suggested amendments. Yes, the first commit is a refactor (a bit tricky to separate further). While our ultimate intent was to move the rendering methods to a separate file, we decided to decouple the methods first and do the migrations later if needed. |
(Travis is having some trouble building the script for OS X. I will try restarting the job again in a while.) |
(Fixed.) |
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.
@preetmishra Thanks for keeping this updated 👍
I continue to like the move of the htmlsoup->urwidmarkup machinery into a state where we could extract it, though looking at this again I'm a little concerned that we've gone very verbose in the recursive calls with the extra parameters. Did we discuss other ways of achieving this? Can we use metadata
? Along similar lines, perhaps we could have a "constant" dict (eg. metadata) and keep dynamic data in the state
dict?
Most of my feedback otherwise is minor, I'd just like to keep the recursive code as clean as possible, if we can :)
zulipterminal/ui_tools/boxes.py
Outdated
@@ -695,12 +695,19 @@ def footlinks_view( | |||
align='left', left=8, width=('relative', 100), | |||
min_width=10, right=2) | |||
|
|||
def soup2markup(self, soup: Any, **state: Any) -> List[Any]: | |||
@classmethod | |||
def soup2markup(cls, soup: Any, server_url: str, metadata: Dict[str, Any], |
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.
metadata
is actually mutable? This got accidentally changed in the commit title?
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.
Yes, metadata
is mutable but it was being used to track immutable objects between recursive calls. I changed the commit description on purpose.
Update: It is now being used to track mutable and immutable objects together to decrease the verbosity.
zulipterminal/ui_tools/views.py
Outdated
self.markup_desc, *_ = MessageBox.transform_content( | ||
rendered_desc, | ||
self.controller.model.server_url, | ||
) | ||
desc = urwid.Text(self.markup_desc) |
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.
Is it necessary to have this here? It feels like it belongs above where the desc
was previously set.
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.
Thanks for pointing it out. Fixed!
text_widget = urwid.Text(footlinks, wrap=wrap) | ||
if padded: | ||
return urwid.Padding(text_widget, align='left', left=8, | ||
width=('relative', 100), min_width=10, | ||
right=2), footlinks_width | ||
else: | ||
return text_widget, footlinks_width |
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 is the only part that depends on wrap
or padded
? That makes it feel separate to the function, ie. the conditional belongs outside of the calling points. The padding is clearly just a wrapper, that is used in one place, and the use of the wrap parameter is less clear - it depends if we're set on returning a widget vs footlinks
.
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 does feel out of place. We could return only the markup from footlinks_view
(+ rename it to markup_footlinks
) and then add wrappers as needed in the caller functions. Thoughts?
8238744
to
f6aef8b
Compare
@neiljp Thanks for the review and pointers. I wasn't inclined towards verbose recursive calls as well. I have moved the data that I want to track amidst the recursive calls into |
f6aef8b
to
175e6ff
Compare
This decouples MessageBox's markup methods, soup2markup(), transform_content() and indent_quoted_content(), for reusability. Additionally, this introduces `metadata` argument for soup2markup() to track objects amidst the recursive calls. Tests amended.
Footlinks support is added in a subsequent commit. Test amended. Fixes zulip#743.
This modifies footlinks_view() to accept a range of configurable parameters and return footlinks_width. Tests amended.
175e6ff
to
b03659c
Compare
Updated to resolve conflicts. |
Heads up @preetmishra, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
@preetmishra I just rebased this to take into account recent changes including the footlinks threshold work and manually pushed this to main ending at 1be52c5 🎉 All seems to work fine - thanks for your work on this and the rebasing! |
While the PR's ultimate intent is to markup the stream description, the first commit has changes to decouple our markup methods.
Commits
transform_content
,soup2markup
andindent_quoted_content
, independent of their class object.transform_content
inStreamInfoView
for markup.footlinks_view
static and more configurable.Fixes #743.