marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.35k stars 156 forks source link

Interpolation and LaTeX in markdown #1640

Closed MarkoMekapses closed 2 weeks ago

MarkoMekapses commented 2 weeks ago

Describe the bug

Even with nesting mo.md calls, it seems impossible to have LaTeX calls with curly braces in a format string cell.... I can see why this would be a result of the normal python interpreter, so I appreciate it may be difficult, but could there (if there isn't already) be a way around this?

Environment

{ "marimo": "0.6.13", "OS": "Darwin", "OS Version": "23.5.0", "Processor": "arm", "Python Version": "3.11.6", "Binaries": { "Browser": "125.0.6422.176", "Node": "--" }, "Requirements": { "click": "8.1.7", "importlib-resources": "6.4.0", "jedi": "0.19.1", "markdown": "3.6", "pymdown-extensions": "10.8.1", "pygments": "2.18.0", "tomlkit": "0.12.5", "uvicorn": "0.29.0", "starlette": "0.37.2", "websocket": "missing", "typing-extensions": "4.11.0", "black": "24.4.2" } }

Code to reproduce

No response

mscolnick commented 2 weeks ago

@MarkoMekapses i am not sure i follow. do you have an example that doesnt work?

akshayka commented 2 weeks ago

@MarkoMekapses , you just need to escape the curly brace. In an f-string, that's done by doubling up on curlies: "{{".

For example:

mo.md(
    rf"""
    \[
    x_{{i}} = {value}
    \]
    """
)

image

notebook link: https://marimo.app/l/t6typj