Skip to content

Markdown rendering empty triple-backtick code fence adds the string "undefined" #12986

@DrShushen

Description

@DrShushen

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Markdown rendering empty triple-backtick code fence adds the string "undefined".

Minimum example:

import streamlit as st

st.markdown("""
Hello

Has content:
```
some_content
```

Is empty, this one is the problem:
```
```

End
""")

Renders like so:

Image

But would expect to have an empty code area, not a code area with the string "undefined" in it.

Reproducible Code Example

import streamlit as st

st.markdown("""
Hello

Has content:

some_content


Is empty, this one is the problem:



End
""")

Steps To Reproduce

  1. Create the above streamlit app.py
  2. Run it

Expected Behavior

Expect the empty triple-backtick code fence with nothing in it to show just an empty grey rectangle.

Current Behavior

Currently the empty triple-backtick code fence with nothing in it to shows a grey rectangle with the string "undefined".

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.51.0
  • Python version: 3.10.19
  • Operating System: Ubuntu 24.04.3 LTS
  • Browser: Chrome

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:markdownRelated to Markdown renderingfeature:st.codeRelated to the `st.code` elementpriority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions