diff --git a/content/develop/api-reference/text/markdown.md b/content/develop/api-reference/text/markdown.md index f6daba668..4e882f18e 100644 --- a/content/develop/api-reference/text/markdown.md +++ b/content/develop/api-reference/text/markdown.md @@ -9,6 +9,8 @@ keywords: markdown, text, formatting, html, display ```python import streamlit as st +import re +import streamlit as st md = st.text_area('Type in your markdown string (without outer quotes)', "Happy Streamlit-ing! :balloon:") @@ -22,4 +24,22 @@ st.markdown('''{md}''') st.markdown(md) ``` - + str: + # Return empty string for anything that is not a valid hex code + if not HEX.match(h): + return "" + return ( + f' {h}' + ) + +hex_values = ["#FF5733", "#1E90FF", "#2ECC71", "#8E44AD"] +html = "".join(chip(h) for h in hex_values) +st.markdown(html, unsafe_allow_html=True) \ No newline at end of file