Skip to content
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

Allow ignoring markdown rendering in st.markdown, st.info, st.warning,... #8546

Closed
3 of 4 tasks
kilpert opened this issue Apr 19, 2024 · 7 comments
Closed
3 of 4 tasks
Labels
feature:markdown type:enhancement Requests for feature enhancements or new features

Comments

@kilpert
Copy link

kilpert commented Apr 19, 2024

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

The output in st.write, st.warning, and st.error is altered (crippled). In my code example, some "_" are deleted from an error message.

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st


"# Unicode str"

error_message = "'bla' does not match '^[0-9]{8}_[A-Z]+[0-9]+_[0-9]+_[A-Z0-9]+$'"

st.code(type(error_message))

"## OK"
st.code(error_message)

"## Bug: some '_' are missing!!!"
st.write(error_message)
st.warning(error_message)
st.error(error_message)



"# Byte str"

error_message = b"'bla' does not match '^[0-9]{8}_[A-Z]+[0-9]+_[0-9]+_[A-Z0-9]+$'"

st.code(type(error_message))

"## OK"
st.code(error_message)
st.write(error_message)

"## Bug: some '_' are missing!!!"
st.warning(error_message)
st.error(error_message)

Steps To Reproduce

  1. Output a complex string with st.write, st.warning, or st.error.
  2. Carefully obsere the output => Some characters can be missing.

Expected Behavior

The output text should be the same as in the variable. No characters should be missing.

Current Behavior

In my example, some "_" are gone, which is bad, e.g. when you want to output the exact regex error message.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.33.0
  • Python version: 3.12.2
  • Operating System: LMDE 6 (faye), Linux 6.1.0-20-amd64 x86_64
  • Browser: Firefox 125.0.1

Additional Information

No response

@kilpert kilpert added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Apr 19, 2024
Copy link

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@Xeno852
Copy link

Xeno852 commented Apr 20, 2024

Hey! This behavior is partially intended. Surrounding words with "_" will turn them into italics which will in turn remove the surrounding underscores.

@LukasMasuch
Copy link
Collaborator

@kilpert Thanks for reporting this issue. I reproduced this here. It's expected that this happens since all these commands render the text as markdown.st.text is rendering it as text without using markdown rendering. Changing this to feature request since it would make sense to allow an option to somehow deactivate markdown rendering, maybe supporting something like in Github Markdown: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#ignoring-markdown-formatting

@LukasMasuch LukasMasuch added feature:markdown type:enhancement Requests for feature enhancements or new features and removed type:bug Something isn't working status:needs-triage Has not been triaged by the Streamlit team labels Apr 20, 2024
Copy link

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Visits

@LukasMasuch LukasMasuch changed the title st.write, st.warning, and st.error cripple unicode str Allow ignoring markdown rendering in st.write, st.info, st.warning,... Apr 20, 2024
@LukasMasuch LukasMasuch changed the title Allow ignoring markdown rendering in st.write, st.info, st.warning,... Allow ignoring markdown rendering in st.markdown, st.info, st.warning,... Apr 20, 2024
@kilpert
Copy link
Author

kilpert commented Apr 22, 2024

You are completely right. I forgot about the markdown. Never really use italic. This is a better way to output error messages:

st.error(f"`{error.message}`", icon="⚠️")

@kilpert
Copy link
Author

kilpert commented Apr 22, 2024

Since this is not a bug, we should close this.

@kilpert kilpert closed this as completed Apr 22, 2024
@Xeno852
Copy link

Xeno852 commented Apr 22, 2024

If you would like to reopen this / make a new issue to allow an option to deactivate markdown rendering I could try to work on this feature. Would I be able to get assigned this @LukasMasuch ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:markdown type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

No branches or pull requests

3 participants