Image in Markdown

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 !

1 Like

Thatโ€™s great, glad itโ€™s working for you!

1 Like

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:
        elif i % 3 == 1:
            title = part
            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. :slight_smile: