Markdown with indent not working with css formatting

I’ve looked at a few questions/answers regarding newline and numbering text but I cant seem to get it working.
I have this function for the text formatting:

def lets_begin_markdown( text):
    styling = "padding-left:100px; " if padding else ""
    styling += "border: 1px solid;"

    html = f"""
        <style>
        [data-testid="stMarkdownContainer"] ul {{
            list-style-position: inside;
        }}
        </style>
        <div style='{styling} font-size: 30px;'>{text}</div>
    """
    
    return st.markdown(html, unsafe_allow_html=True)

but when I call the function I don’t see my other formattni, ie. the padding, or the border or the font size… i only see the list style… which is good but not what i expected.

text_to_begin ="""
The following list won't indent no matter what I try:
1.  Item 1
2.  Item 2
3. Item 3
"""
lets_begin_markdown(text_to_begin)

It looks like the picture i’ve attached.

Hi @KristiVice1,

Thanks for sharing this question!

Do you have an example of how you would like the end product to look like?

I tried modifying your code above and got this so far:

import streamlit as st

def lets_begin_markdown(text, padding=True):
    padding_style = "padding-left:100px;" if padding else ""
    border_style = "border:1px solid;"
    font_style = "font-size: 30px;"
    
    html = f"""
    <style>
        [data-testid="stMarkdownContainer"] ul {{
            list-style-position: inside;
            {padding_style}
        }}
        [data-testid="stMarkdownContainer"] {{
            {border_style}
            {font_style}
        }}
    </style>
    <div>
        {text}
    </div>
    """
    
    return st.markdown(html, unsafe_allow_html=True)

text_to_begin = """
The following list won't indent no matter what I try:
1. Item 1
2. Item 2
3. Item 3
"""

lets_begin_markdown(text_to_begin)

1 Like

Thank you!

1 Like

Glad it worked! Happy Streamlit-ing! :balloon:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.