| 函数签名[source] | |
|---|---|
st.markdown(body, unsafe_allow_html=False, *, help=None) | |
| 参数 | |
body (any) | The text to display as GitHub-flavored Markdown. Syntax information can be found at: https://github.github.com/gfm. If anything other than a string is passed, it will be converted into a string behind the scenes using str(body). This also supports:
|
unsafe_allow_html (bool) | 是否在body中渲染HTML。如果为False (默认),在body中找到的任何HTML标签将被转义并 因此被视为原始文本。如果为True,body中的任何HTML 表达式将被渲染。 向您的应用程序添加自定义HTML会影响安全性、样式和 可维护性。 注意 如果您只想插入HTML或CSS而不使用Markdown文本, 我们建议使用st.html代替。 |
help (str) | 一个可选的工具提示,显示在Markdown旁边。 |
示例
import streamlit as st st.markdown("*Streamlit* is **really** ***cool***.") st.markdown(''' :red[Streamlit] :orange[can] :green[write] :blue[text] :violet[in] :gray[pretty] :rainbow[colors] and :blue-background[highlight] text.''') st.markdown("Here's a bouquet —\ :tulip::cherry_blossom::rose::hibiscus::sunflower::blossom:") multi = '''If you end a line with two spaces, a soft return is used for the next line. Two (or more) newline characters in a row will result in a hard return. ''' st.markdown(multi)
import streamlit as st
md = st.text_area('Type in your markdown string (without outer quotes)',
"Happy Streamlit-ing! :balloon:")
st.code(f"""
import streamlit as st
st.markdown('''{md}''')
""")
st.markdown(md)
还有问题吗?
我们的 论坛 充满了有用的信息和Streamlit专家。