-
Notifications
You must be signed in to change notification settings - Fork 4k
Make st.write use st.html when _repr_html_ is present. #9910
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
Conversation
This also changes some behavior: 1. When unsafe_allow_html=False AND _repr_html_() did not contain HTML tags we used to send its output to st.markdown(). This behavior is now removed. Instead, the output is handled like a normal object (that is, with st.help). 2. Removes _repr_html_ from *Connection objects. This didn't really buy us anything, and was just weird. Also, this was the reason for adding behavior #1 in the first place.
|
FYI: We talked about these changes here |
kmcgrady
left a comment
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.
Overall looks good. You might need to rebase the branch to get the latest playwright changes to work properly.
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.
These screenshots are just random issues and are not tied to the change to html, right? It doesn't seem like it should be calling html on this, but I guess I didn't expect these screenshots. Just wanted to confirm.
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.
Yeah that's what it looks like. But a merge didn't help. Super weird.
Will look into it in a little bit.
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.
Ok, I can't tell what could be causing it. These just seem to be flakes.
Since st_write_test.py was breaking often, I split it into multiple files and it seems to be better now. But then st.video_test.py started failing 🤷♂️
Make st.write use st.html when _repr_html_ is present. ## Describe your changes 1. When `_repr_html_()` is present in an object, `st.write` now displays the HTML using `st.html()` rather than `st.markdown()` (assuming `unsafe_allow_html=True`). 1. When `unsafe_allow_html=False` AND `_repr_html_()` did not contain HTML tags we used to send its output to `st.markdown()`. This behavior is now removed. Instead, the output is handled with `st.help()` like any other object. 1. Removes `_repr_html_()` from `*Connection` objects. This wasn't really buying us anything, and was just weird. Also, this was the reason for adding behavior #2 in the first place. 1. This is totally unrelated to the above, but is so small I didn't want to create a separate PR for it (though, LMK if you want me to!): Remove an old check for an environment variable that Streamlit's Atom plugin from 2018-19 used to depend on. That plugin no longer exists, so we can safely remove this. ## GitHub Issue Link (if applicable) n/a ## Testing Plan - ~~Explanation of why no additional tests are needed~~ - Unit Tests (JS and/or Python): ✅ Included! - E2E Tests: 🟢 No new tests added, but this is already well-tested. - Any manual testing needed? 👎 No need. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Make st.write use st.html when repr_html is present.
Describe your changes
When
_repr_html_()is present in an object,st.writenow displays the HTML usingst.html()rather thanst.markdown()(assumingunsafe_allow_html=True).When
unsafe_allow_html=FalseAND_repr_html_()did not contain HTML tags we used to send its output tost.markdown(). This behavior is now removed. Instead, the output is handled withst.help()like any other object.Removes
_repr_html_()from*Connectionobjects. This wasn't really buying us anything, and was just weird. Also, this was the reason for adding behavior Improve caching code #2 in the first place.This is totally unrelated to the above, but is so small I didn't want to create a separate PR for it (though, LMK if you want me to!): Remove an old check for an environment variable that Streamlit's Atom plugin from 2018-19 used to depend on. That plugin no longer exists, so we can safely remove this.
GitHub Issue Link (if applicable)
n/a
Testing Plan
Explanation of why no additional tests are neededContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.