-
Notifications
You must be signed in to change notification settings - Fork 4k
Allow markdown in caption of st.image
#10075
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
caption of st.imagecaption of st.image
| })) | ||
|
|
||
| export const StyledCaption = styled.div(({ theme }) => ({ | ||
| fontFamily: theme.genericFonts.bodyFont, |
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.
Note: We can remove these styling properties because they are handled by StreamlitMarkdown if isCaption is set.
caption of st.imagecaption of st.image
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 have it on my list to fully remove all snapshot tests from the label_markdown e2e test since it is a bit of a pain (huge number of snapshots based on a variety of different elements). I think it's better that every element e2e test script (st_image.py in this case) contains at least one snapshot test that demonstrates that it supports markdown (a short label with a couple of markdown aspects). And these specific details - e.g. st.image caption should not support table markdown - is something that might be better tested 1) via a non-snapshot e2e tests that just checks that a table markdown does not get converted to table HTML in the DOM or maybe 2) via an RTL unit test (-> ImageList.test.tsx)
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 I agree, label_markdown is really annoying. Should I already move the tests to the st.image tests, or should I just leave them in there for now, and we clean it up in one go later? Both fine with me, but doing it in one go might make it more consistent / not make us end up with 5 different ways of how we test markdown support.
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, ok... I added a tech debt item here to refactor the label_markdown e2e test.
lukasmasuch
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.
LGTM 👍
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, ok... I added a tech debt item here to refactor the label_markdown e2e test.
## Describe your changes This PR allows using markdown features for the `caption` parameter of `st.image`. It has the same restrictions as widget labels, e.g. no tables or horizontal rules. ## GitHub Issue Link (if applicable) Closes streamlit#6808 ## Testing Plan - Added e2e tests in `label_markdown_test.py`. This is obviously not a widget label, but I think it makes the most sense to test it there since that file already contains all the strings for valid or invalid Markdown. If that's not desired, I can also move the test to `st_image_test.py`. - Did not add unit tests because I think the e2e test should cover it well enough and this is a pretty small feature. Plus, I don't think we have unit tests for the other label markdown tests. - Had to update a lot of snapshots because of subpixel movement. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. --------- Co-authored-by: Johannes Rieke <[email protected]>
Describe your changes
This PR allows using markdown features for the
captionparameter ofst.image. It has the same restrictions as widget labels, e.g. no tables or horizontal rules.GitHub Issue Link (if applicable)
Closes #6808
Testing Plan
label_markdown_test.py. This is obviously not a widget label, but I think it makes the most sense to test it there since that file already contains all the strings for valid or invalid Markdown. If that's not desired, I can also move the test tost_image_test.py.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.