Hey! Used this to insert images modifying a lil bit of the function to add a personal touch and it worked perfectly, thanks a lot !
That’s great, glad it’s working for you!
Here’s the simplest most elegant solution I ended up using:
def st_markdown(markdown_string):
parts = re.split(r"!\[(.*?)\]\((.*?)\)", markdown_string)
for i, part in enumerate(parts):
if i % 3 == 0:
st.markdown(part)
elif i % 3 == 1:
title = part
else:
st.image(part) # Add caption if you want -> , caption=title)
I let AI write that REGEX for me, because my brain doesn’t do REGEX, so please check that.
It works, Good idea!
works like a charm