Replies: 2 comments
|
I find the slideshow view a pretty cool feature, sometimes I want to show the code that is being run along some context information in the slide, this of course looks prettier if said context is shown as markdown. The problem is that when I try to do this, the show_code command always appears as above. I also tried a cell as bellow, which shows the mo.md command as I was thinking that show code only goes up to the line is being called: def foo():
pass
code = mo.show_code()
mo.md(f"""### Code title
Some info regarding the code is being run
{code}""")After looking at the code I saw that marimo refers to the whole cell and deletes the show_code() appearances. I think a good solution would be to delete the entire line where the show_code() call is being done when no object argument is given. |
|
You can grab the # Define this function somewhere, e.g. in a library.
import re
def show_unhidden(start_seq: str=r'# ---Hide---', end_seq: str=r'# ---Unhide---'):
pattern = r'(\n)?' + re.escape(start_seq) + r'(.*?)' + re.escape(end_seq) + r'(\n)?'
text = mo.show_code().text
subbed = re.sub(pattern, '', text)
return mo.Html(subbed)This next part would goes in a Marimo cell. my_val = 3
# ---Hide---
code = show_unhidden()
mo.vstack([my_val, code])
# ---Unhide--- |

Uh oh!
There was an error while loading. Please reload this page.
I try to insert the code from another cell to markdown for documentation. However, when I try to assign
show_code()to a variable, it includes the variable itself:The following cell
will be should as
Is there a way to get rid of the
code =?All reactions