Markdown cells in Pluto

Hello! I think this could be a nice feature: be able to make some cells md cells.

The idea is the following:

  1. Click to button next to the “fold” button
  2. Then the code is wrapped by md"""<your code>""", as with Ctrl-M.

image

  • Extra feature: hide md""" and """ from the code and highlight as markdown. This could apply for Ctrl-M too.

UPDATE: I’m at this point https://github.com/i-apellaniz/Pluto.jl/tree/markdown-toggle at the moment.

4 Likes

Hi,

Pluto cells are always Julia code, hiding the md""" parts would break with this design principle.
If adding a button for markdown (as an alternative to Ctrl-M) is beneficial is a matter of taste. I suggest to file an Issue at https://github.com/fonsp/Pluto.jl first in order to discuss it.

Yes! I also like that the code is saved as Julia code. Since you can send the file to someone else and somehow he/she can run it. But things can be more user friendly, and markdown is everywhere in a Pluto notebook. I have made some more progress on this and now one can toggle code/markdown.

I post it on discourse since I thought that it’s a better place to discuss such a thing. Let me know please why you think it is better to post on GitHub

Sin nombre

3 Likes

cc @fonsp

2 Likes

As a user, I want to give a huge thumbs up to this. It looks fantastic (pretty), and I have missed this feature a lot. I thought about suggesting this myself at some point, so kudos to you for making it happen!

4 Likes

I would add the I think that markdown cells should hide the code by default after being excuted.

9 Likes

Very cool! We are adding a context menu to cells, maybe this could go there! bit of info here Temporary Execution barrier by lungben · Pull Request #985 · fonsp/Pluto.jl · GitHub

As for hiding the md""" and syntax-highlighting markdown, that would be fantastic! I would add markdown keyboard shortcuts and maybe buttons for B and I and such. On the other hand, one nice thing about showing the md""" is that it might show people that they interpolate with $ and that they can use it like other Julia objects, e.g. intro = md"Hello!"

My goal for this is a more general concept of inline GUI editors for common syntax patterns: Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.

4 Likes

It looks like observablehq recently implemented this feature. A very emotional response expressing similar concerns: JavaScript, Markdown, HTML, and TeX Cell Modes. OH MY! - #4 by jwoLondon - Announcements - The Observable Forum

2 Likes

I wanted to highlight some of the content in the discussion @fonsp linked to:

Confrontation anxiety / low work self-esteem friendly summary :blush::

The gains don’t out-weight the losses.

  • Template literals are very modular and compose nicely. Typed cells don’t.
  • Template literals empower the community and promote experimentation and collaboration.
  • Having to write ~~~ instead of ``` is a non issue.
  • Additional keyboard shortcuts and mouse operations introduce friction.
  • They don’t play nicely with copy and paste.
  • More UI means less interoperability.
  • This adds more maintenance burden on an obviously overworked team.

Thanks for trying tho :smiling_face_with_three_hearts:!

There is a “Frustration fuelled rant :wink: :” after this, saying among other things that

I’ve used other notebooks with typed cells like nextjournal 1 and starboard 2, typed cells plain suck.

Even though I would love prettier markdown cells, and fully agree that it should be a priority due to a large proportion of Pluto-cells being markdown, I really feel like there are some good points raised in the Observable discussion. So I would like to propose an idèa I just had, that I feel has the potential to strike a good middle ground:

The suggestion:

There is a toggle to markdown-format a cell. But this toggle simply adds md""" as the first line and """ as the last line, and makes the first and last lines low constrast. This has the effect of mostly hiding it to the user, without actually changing any of the code in the cell, which should result in none of the typical downsides of typed cells! By having a “markdown-mode”, one could also activate propper highlighting as opposed to the uniform brown. Toggling markdown-mode off would simply delete the first and last line, and change the highlighting.

5 Likes

Thank you for the responses! What @TheLateKronos says is 100% reasonable. We can call them cell “views”, instead of cell “modes”, since the underlaying code with either approach is always valid Julia code.

I think the main motivation to do this kind of changes is to engage new people, or people with bad memory and a bit lazy as me :grinning_face_with_smiling_eyes: ! I would like the highlight for markdown, and the shortcut to toggle it was a nice discovery!

On this line, I think markdown editing should be doable at some point from the output instead of the cell itself. One could start a new cell, toggle it to markdown view (which could fold the code by default), and start the cursor in the output of the cell. On that context there could be some buttons and shortcuts in a similar way as for "inline GUI"s, as @fonsp has shown. Reaaally nice feature!!

FTR: contentEditable: true when toggling to markdown-view :partying_face:

1 Like