How to stop attempted K/LaTeX rendering of "$1 million" or "$100,000"

Summary

Is there a way to stop the attempted KaTeX rendering of words like “$100 million” and “$1 billion” with st.write or st.markdown? Do I just need to strip out all “$”? Is there a special way to escape the “$” character? Thanks!

Steps to reproduce

Code snippet:

st.write("text with phrase like $100 million")
st.markdown("text with phrase like $1 billion")

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

Regular text rendering of “$100 million”.

Actual behavior:

Attempted KaTeX rendering. Makes the text messy.

Debug info

  • Streamlit version: (get it with $ streamlit version) 1.21.0
  • Python version: (get it with $ python --version) 3.10.6
  • Using Conda? PipEnv? PyEnv? Pex? PyEnv
  • OS version: MacOS 13.2.1
  • Browser version: Chrome Version 112.0.5615.49 (Official Build) (arm64)

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.

Links

  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

lol at myself. Here’s the solution in case anyone googles in the future.

text = text.replace(“$”, “$”)

edit: the blackslash escaped. put a backslash before the $.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.