Open chicolucio opened 2 years ago
@chicolucio Thanks for this suggestion!
I think that the easiest way to solve would be simply add the line on Streamlit code itself since the extension is provided by KaTeX and Streamlit uses KaTeX to render every other LaTeX code.
I agree that this way would be the best to solve this specific issue, and it seems to be a simple addition to our st.latex
command. I have forwarded this to our product team.
Any news on this issue?
Problem
I would like to render chemical formulas in my app. I see here that Streamlit uses KaTeX to render LaTeX. However, the mhchem LaTeX package is not provided in the core KaTeX. It is provided as an extension by KaTeX.
Solution
The following script should be added to the
<head>
tag to allow chemical formula rendering with KaTeX:There is no direct way to add scripts to the
head
of a page using Streamlit.On https://github.com/streamlit/streamlit/issues/969 it was suggested that arbitrary JavaScript code blocks should be allowed. However, the context in my issue is different, since the script must be in the
head
tag.On https://github.com/streamlit/streamlit/issues/2262 it is also discussed the need of JavaScript injection. Again, I think that my issue is different since the script must be inside the
head
tag.On the issue cited above, it was proposed to inject arbitrary JavaScript via a
st.javascript()
type command. I would add a parameterhead
when the script must be inside thehead
tag:That said, I think that the easiest way to solve would be simply add the line on Streamlit code itself since the extension is provided by KaTeX and Streamlit uses KaTeX to render every other LaTeX code.
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.