marimo icon indicating copy to clipboard operation
marimo copied to clipboard

Change md code-block style

Open dmadisetti opened this issue 1 year ago • 10 comments

Description

Current codeblock style is ```{.python.marimo}

I think code blocks should:

  • [x] syntax support in VScode out of the box ({.python} does the trick)
  • [ ] syntax support in github (missing)
  • [x] Have a loose check pattern (currently checks for just "{.python.}")
  • [x] Register as a quarto execution block
  • [x] Enable args (e.g. {.python.marimo name="whatever"}
  • [ ] Be pretty syntax ({.python.marimo} is a little weird)

Suggested solution

```python {marimo}

  • [x] syntax support in VScode out of the box (python does the trick)
  • [x] syntax support in github (yep)
  • [x] Have a loose check pattern (maybe just check for "{marimo}")
  • [ ] Register as a quarto execution block (this format breaks pandoc pretty bad)
  • [x] Enable args (e.g. python {marimo name="whatever"}
  • [x] Be pretty syntax (I like it!)

Alternative

Making an issue for comments, but maybe better changed to a discussion post? I'm think asking on discord and getting feedback if people are actually using markdown.

Additional context

@mscolnick suggestion!

dmadisetti avatar May 22 '24 20:05 dmadisetti

Others:

```{marimo} python

assert None == 123, "string"

```{python}

assert None == 123, "string"

```python .marimo (no good for pandoc)

assert None == 123, "string"

Other suggestions:

  • Change github: https://github.com/github-linguist/linguist/blob/master/lib/linguist/languages.yml
  • Change pandoc: https://github.com/jgm/pandoc/blob/d01f2ac515ae3b744a476100f72050ca5446f328/src/Text/Pandoc/Readers/Markdown.hs#L684

dmadisetti avatar May 22 '24 20:05 dmadisetti

Ok, just found this: https://github.com/jgm/pandoc/pull/8187

So these are fine

```python {.marimo}

assert None == 123, "string"

or ```python {#marimo}

assert None == 123, "string"

or ```python {marimo=}

assert None == 123, "string"

but still might be worth creating an issue for null attributes to make the ```python {marimo} syntax work

dmadisetti avatar May 22 '24 20:05 dmadisetti

I think i like python {.marimo} the best (unless can get python {marimo})

mscolnick avatar May 22 '24 21:05 mscolnick

The fix in pandoc looks pretty trivial: https://github.com/jgm/pandoc/issues/9791

I think it's going to be a matter of will- but I think it's good functionality. Hopefully, I get a positive response

dmadisetti avatar May 22 '24 22:05 dmadisetti

One downside to this notation is that it breaks in marimo markdown itself (current renders no styling, but proposed does not render)

https://marimo.app/l/oaqlop


I might pick this up sooner than later with backwards compat in mind. As I'm working more directly with the notebooks (esp, with the kiosk mode picking up speed), the current notation is a little cumbersome

I don't think python {marimo} is happening anytime soon, so will put in python {.marimo}. @mscolnick if the SQL changes are coming up, I can make sure sql {.marimo} works too

dmadisetti avatar Jun 25 '24 21:06 dmadisetti

amazing! i agree it would be worth doing sooner to avoid too much breakage. If backwards compat is hard, we can make a breaking change and bump acccordingly (probably could read backwords compat and then write forwards)

mscolnick avatar Jun 25 '24 21:06 mscolnick

Just checks to see if {.*python.*} is in the code block,

I think it should check for {.*marimo.*}. I think this will make it automatically backwards compatible?

dmadisetti avatar Jul 03 '24 18:07 dmadisetti

Will submit PR once https://github.com/facelessuser/pymdown-extensions/pull/2470 is released, conditional on version number

dmadisetti avatar Sep 27 '24 14:09 dmadisetti

not sure what the backwards compatibility issue is with the planned python {.marimo} code fence name. maybe using

```python {.python.marimo}
print("python code")
```

could avoid the compatibility problem?

zhuoqiang avatar Jan 09 '25 15:01 zhuoqiang

Backwards compat issue was with regard to opening old format and saving in the new format. I don't fully remember the issues I ran into since it's bee a couple month, but just pushed up the branch I had locally as a draft: #3387

dmadisetti avatar Jan 09 '25 16:01 dmadisetti