Skip to content

Nested Markdown Code Blocks #6363

@slcoplin

Description

@slcoplin

Describe the bug

Nesting mo.md(md.md()) clears mutliline code blocks.

Expected:

multiline
text

Actual mo.md(f'{mo.md(block)}'):

multiline text

Actual mo.md(f'{mo.as_html(mo.md(block))}'):

multiline text

Details

For block defined as:

block = """
```
multiline
text
```
"""

I've managed to work around this for a long time by just passing around strings instead of marimo objects, but I can't find a workaround if my code block is inside an accordion.

Will you submit a PR?

  • Yes

Environment

I'm using marimo.app and locally,

{
  "marimo": "0.8.22",
  "OS": "Darwin",
  "OS Version": "24.6.0",
  "Processor": "arm",
  "Python Version": "3.8.11",
  "Binaries": {
    "Browser": "140.0.7339.133",
    "Node": "v20.9.0"
  },
  "Dependencies": {
    "click": "8.1.3",
    "importlib-resources": "6.1.1",
    "jedi": "0.19.2",
    "markdown": "3.7",
    "pygments": "2.19.1",
    "pymdown-extensions": "10.15",
    "ruff": "0.4.2",
    "starlette": "0.44.0",
    "tomlkit": "0.13.2",
    "typing-extensions": "4.9.0",
    "uvicorn": "0.33.0",
    "websockets": "12.0"
  },
  "Optional Dependencies": {
    "pandas": "1.4.4"
  }
}

Code to reproduce

marimo.app example

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions