Skip to content

Commit

Permalink
fix: markdown formatting (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPokorny authored Jan 3, 2025
1 parent 80fa95c commit c424808
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/python/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ def patch_streamlit():
# Title -- replace by custom element, allow subtitle
st.title = lambda heading, description, **kwargs: st.markdown(f'<div class="bee-st-title"><div class="bee-st-title-heading">{heading}</div><div class="bee-st-title-description">{description}</div></div>', unsafe_allow_html=True)

def fix_markdown(body):
body = re.sub(r"^•", "*", body, flags=re.MULTILINE) # Replace Unicode bullet points
body = re.sub(r"^(#+ .+\n)[=-]+$", r"\1", body, flags=re.MULTILINE) # Replace combined (# and underline) headings
return body

# Markdown -- fix wrongly generated formatting
st_markdown = st.markdown
st.markdown = lambda body, *args, **kwargs: st_markdown(fix_markdown(body), *args, **kwargs)

# Write -- fix wrongly generated formatting, but only for strings
st_write = st.write
st.write = lambda *args, **kwargs: st_write(*(fix_markdown(arg) if type(arg) is str else arg for arg in args), **kwargs)


async def run():
try:
Expand Down

0 comments on commit c424808

Please sign in to comment.