-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopting a text-based diagram syntax in Jupyter Markdown #101
base: master
Are you sure you want to change the base?
Conversation
6242983
to
0306b10
Compare
Hi folks! It's been a week, and we've collected a few emoji ❤️ . it was my hope to do the work to get this into the JupyterLab 4/Notebook 7 release window, which is rapidly closing. Any feedback welcome! |
What are the expectations on Jupyter clients that comply with this addition? For example, are they expected to:
|
As a "living" dependency with maintenance costs, I think this has to be the assumption: as noted, changes can happen in minor versions, and 9.x is still getting releases, which speak well the the upstream maintainer attention to detail. That being said, the Perhaps if rendering fails, the right play is to fall back to the the raw text, which could convey some meaning... ideally with grammar-aware syntax highlighting, but then that can "fail".
Perhaps. But I think throwing the kitchen sink, including the new, sharp knives, isn't the worst play. The one that kills me is the ElkJS backend for |
@manics thinking more about it: i've also updated the JupyterLab PR with a treatment of how an "unparseable" might be treated... moving it down to the "warning" class of feedback seems reasonable, as again, you can still kinda tell what is going on in the diagram by reading the text.
|
and the full `d3` metapackage. Some advanced features use the `cytoscape` and `elkjs` | ||
_rendering engines_, but are only loaded when needed. | ||
|
||
## Unparseable Diagrams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manics here's me expounding a bit more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And for reference, here's how GitHub handles unparseables:
flowchart LR
a --> b -->
Note that it:
- puts the (undismissable) error up front with (unhighlighted) source below
- does not provide the (semi-) helpful grammar message
- allows for copying (but not viewing) the raw source
|
||
...and they should _mostly_ render the same way everywhere. | ||
|
||
_MermaidJS 10_ also includes a number of new diagrams, not available on earlier major |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manics i've split out the diagrams and features not available in <10
I note the proposed syntax diverges from the syntax used by MyST, which is the flavour of md preferred for writing Jupyter Book documents. For example, via https://myst-tools.org/docs/mystjs/diagrams :
The There are also various flavours of IPython magic that support text2diagram rendering (example). |
GitHub has just ```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
``` |
@westurner The MyST parser renders the In general, I get the feeling From a "content creator" end user perspective, writing content, the |
In MyST, the convention is In the |
I believe that the discussion on the use of braces or not is orthogonal to this JEP. Jupyter (Notebok, Lab, etc) currently de facto uses GtiHub-flavoured markdown and this JEP follows that; there is a separate JEP about allowing other Markdown flavours: #99 and if both will be accepted everyone will be happy. But should only this one be accepted, I think we should not introduce discrepancies by changing to braced format for only one singular case. |
👍 to supporting whatever GitHub flavored markdown supports. Too bad they didn't include mermaid in their spec. |
FWIW YAML (and YAML-LD with an implicit @context) probably has a better-defined one-line grammar than the existing MyST Markdown parser and JupyterBook. |
|
I want to start off by conceding that having a text-to-graphic diagramming standard within the notebook would be useful, and acknowledge the significant amount of effort and thoroughness that's been put into preparing this JEP. One of the challenges I see with this proposal is that an external tool is being used without reference to the version of the tool that is part of the document containing the diagrams. To make this discussion more concrete: Mermaid JS adds a new chart types in minor versions, 10.2.0 introduced quadrant chart, for example. A new user could start using these quadrant charts, or other Mermaid JS features which are not in the version of Mermaid JS that shipped with whatever Jupyter tool they are using, and be frustrated when it doesn't work. Similarly, two users sharing a notebook document but using different versions of the same Jupyter tool which happen to bundle different versions of Mermaid could end up with a proper render of a diagram for one of them, and an un-rendered/error diagram in another. This doesn't have to be different users, the same situation can arise from one user using a combination of Jupyter tools (a JupyterLab version that has adopted the latest Mermaid JS version, and an nbconvert version that is using an older version). I hope you can understand how an unspecified and possibly changing dependency can also lead to a complement problem, where diagrams that used to render stop rendering as features in MermaidJS are deprecated and removed, and the Mermaid JS version changes. One of the differences I see between this and an analog in code cells caused by syntax changes in programming code languages is that at least the previous rendered results are available when receiving a notebook document, even if the recipient lacks a kernel matching programming language version. Finally, it seems like this introduces a javascript runtime environment requirement for converting a notebook to a PDF document. Notebooks using For these reasons, I am voting against this proposal. I would prefer an alternate path where we come up with a way to try out extensions to markdown like this without committing the project to a particular one. That way, even if JupyterLab and Notebook 7+ ship supporting mermaid syntax, others are also possible, including the ones mentioned in the JEP, or still others, like Wavedrom, or ones that haven't been made yet. One way to think about this JEP is that it adds a secondary "kernel" to documents, and further blurs the operational distinction between code and markdown cells, as markdown cells now contain "code" (in the form of diagram syntax) and that new markdown "code" relies on a particular "kernel" (version of mermaidJS). But I can also see how this could be a staring point for further refinement later, the way we used to have words that were specialized for Python (what started as "pyin" and "pyout" instead of the current "execution_count" and "execution_result"). Should this proposal pass as is, I would like to encourage further work to address cross-compatibility, such as capturing the Mermaid JS version used during authoring into the ipynb document, so other tools have a chance of resolving the ambiguity. To me, the alternative of capturing the MermaidJS version within the notebook document format seems like it would lead to too many minor version updates just for this one component. Another proposal to address some of these concerns would be to add a rendered version of the diagrams (SVGs) as attachments to the markdown cell, with some convention for how to unambiguously use a pre-rendered version in cases where rendering is unavailable (no javascript) or fails (MermaidJS version mismatch). |
Based on @ivanov comment on #101 (comment) and on question shared yesterday at the SSC meeting by @ibdafna I am converting my I am also formalising here some feedbacks/questions I have asked yesterday during yesterday meeting:
|
Presumably it is orthogonal, as this proposed change only adopts existing, widely-adopted syntax with relatively sane failure modes. Put differently, if something in 103 breaks due to this PR, it will probably break other de facto GFM+ features employed on many other platforms. Welp, it would have to pile on a significant amount more metadata to be precise. To dovetail with one of @ivanov's key points: let's not be overly-harsh on little old mermaid: we have a bunch of non-portable things done in markdown (and other Jupyter-adopted the following is getting totally off topic, now, please ignore for the purposes of reviewing this proposal...Frankly, I'm of a mind that the current model of many best effort tools (e.g. markdown, widgets, etc) really don't provide the level of reproducibility we yearn for. The above-mentioned "typesetting kernel," (also discussed in a number of other places) is indeed likely the high road. I think the path there would pretty much abolish I'd go on to abolish But these are topics for a whole other day, the discussion around which would be... greatly facilitated by having a portable diagram syntax! ;P
Mermaid has been running like a champ for just a hair shy of a decade, and has a (number of) formal, closed-form grammars, but indeed, just a single implementation. I'd just like to be able to use it in Jupyter tools. This proposal tries to make as few uninformed claims about other syntaxes/tools/features... just the diagram ones that have proven stable enough for me to spend my time (trying) to implement against, and my findings in using them. |
Following the discussion at the SSC meeting yesterday, the mermaid JS website lists the available integrations. In addition to Git webservice (such as GitHub), online editing platforms are also integrating it, like Notion, Observable, HackMD. |
Yep, this is the called out in the summary as one of the main motivators of why this proposal concentrates on just one diagram format with just one markdown syntax. Even if a platform doesn't offer this syntax natively, open source platforms Jupyter already uses (such as Discourse) can enable it via first-party plugin. That Discourse plugin offers one "metadata" extension to the syntax ( |
I think the distinction between hosted services, such as GitHub or Discourse, and standalone applications that need to support the exchange of documents in an agreed upon format (e.g., Jupyter notebooks) is important. Looking at the list of integrations I see that code editors exclusively use plugins to enable Mermaid.js support, and that nearly all the documentation generations tools do, as well. This suggests that the current practice for standalone applications is to recommend or maintain a well-supported plugin. |
Hey folks, I think we should pause voting here temporarily— I think the voting pattern on this JEP presents an interesting problem we haven't faced before; we should use this opportunity to learn/define how to handle this type of situation going forward. While this JEP technically has more "Yes" votes (4) than "No" votes (1) at this point, there is an equal number of abstentions (4). It would make me extremely uncomfortable to pass this JEP without more buy-in from the SSC. Further, when I read this thread, the temperature in the room that I'm perceiving is that these abstentions as "soft no"s—folks feel hesitant towards the proposal, but don't want to be the blocker to acceptance. If we are seeing a majority of these types of abstentions, (I believe) this raises a flag. I believe SSC should work together to ensure that every member has enough time/info to formulate a firm opinion on each JEP (also, the SSC should ensure this happens in a timely manner—we'll get better at this over time). Otherwise, abstentions can become a crutch and allow JEPs to pass without more thorough investigation. I think this JEP needs more discussion before voting, so I propose we pull it out of voting phase temporarily. I'll mention this in our next SSC meeting. I want to thank @bollwyvl for proactively engaging every question/concern mentioned here and giving thorough responses. Also, thank you to everyone who has given careful comment/feedback on the JEP so far. I think this exposed a gap in the SSC that we need to address. I've opened an issue on the SSC team-compass to discuss further, jupyter/software-steering-council-team-compass#4. I'll update this thread on our discussion after next week's meeting. |
In this particular JEP, I have abstained not because of the JEP content itself (and I really want to thank @bollwyvl for the quality work he is doing here, and at a lot of other places), but rather because of the lack of definitions of Markdown outside of this JEP. This is not the first time I have similar feeling where a JEP as such sounds good, and it is easier to say yes to it, instead of looking wider, which in general, sounds synonym to "blocking", or "moving much slower". I don't expect anyone to agree that it is preferable to look wider, instead of having tiny steps even on unstable and unclear things, but I felt maybe useful to share the reasons for my abstention. |
Hello folks! This JEP proposes adopting this syntax:
Which renders all over as:
It was written entirely within a checkout of this PR, which you can try out directly on .
Thanks!
Resolve #100
Voting from @jupyter/software-steering-council