jonsequitur / jonsequitur/dotnet-repl

Run fails when starting with a Mermaid cell without a Markdown cell before

Open
#91 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
844
Forks
42
PR merge metrics
No merged PRs in 30d

Description

I am trying to run a `--run` command with `--exit-after-run`, but it looks to fail when there is a Mermaid cell. But there is no bug if the Mermaid cell has a Markdown cell before.

Here is a dib file starting by a Mermaid cell:

```
#!meta

{"kernelInfo":{"defaultKernelName":"csharp","items":[{"aliases":[],"languageName":"csharp","name":"csharp"}]}}

#!mermaid

flowchart LR

A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]

```

I am running the following command:

```
dotnet repl --run test_mermaid.dib --exit-after-run --output-path output.ipynb
```

The output ipynb displays an error `Unrecognized command or argument '#!mermaid'.`:

```
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_repl_cellExecutionStartTime": "2023-11-06T14:21:35.3153963+01:00",
"dotnet_repl_cellExecutionEndTime": "2023-11-06T14:21:35.3564921+01:00",
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
}
},
"outputs": [
{
"ename": "Error",
"evalue": "Required command was not provided.\r\nUnrecognized command or argument '#!mermaid'.",
"output_type": "error",
"traceback": []
}
],
"source": [
"#!mermaid\n",
"\n",
"flowchart LR\n",
"\n",
"A[Hard] -->|Text| B(Round)\n",
"B --> C{Decision}\n",
"C -->|One| D[Result 1]\n",
"C -->|Two| E[Result 2]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
},
"language_info": {
"file_extension": ".cs",
"mimetype": "text/x-csharp",
"name": "C#",
"pygments_lexer": "csharp",
"version": "10.0"
},
"polyglot_notebook": {
"defaultKernelName": "csharp",
"items": [
{
"name": "csharp"
}
]
},
"dotnet_interactive": {
"defaultKernelName": "csharp",
"items": [
{
"name": "csharp"
}
]
}
},
"nbformat": 4,
"nbformat_minor": 5
}
```

If there is a Markdown cell before the Mermaid cell, it seems to work.

```
#!meta

{"kernelInfo":{"defaultKernelName":"csharp","items":[{"aliases":[],"languageName":"csharp","name":"csharp"}]}}

#!markdown

text

#!mermaid

flowchart LR

A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
```

The output ipynb without errors:
```
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"dotnet_repl_cellExecutionStartTime": "2023-11-06T14:25:08.8096961+01:00",
"dotnet_repl_cellExecutionEndTime": "2023-11-06T14:25:08.8511904+01:00"
},
"source": [
"text\n",
"\n",
"#!mermaid\n",
"\n",
"flowchart LR\n",
"\n",
"A[Hard] -->|Text| B(Round)\n",
"B --> C{Decision}\n",
"C -->|One| D[Result 1]\n",
"C -->|Two| E[Result 2]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
},
"language_info": {
"file_extension": ".cs",
"mimetype": "text/x-csharp",
"name": "C#",
"pygments_lexer": "csharp",
"version": "10.0"
},
"polyglot_notebook": {
"defaultKernelName": "csharp",
"items": [
{
"name": "csharp"
}
]
},
"dotnet_interactive": {
"defaultKernelName": "csharp",
"items": [
{
"name": "csharp"
}
]
}
},
"nbformat": 4,
"nbformat_minor": 5
}
```

I did a few tests:
* 1 Mermaid cell -> bug
* 1 Markdown cell, 1 Mermaid cell -> ok
* 1 Markdown cell, 1 C# cell, 1 Mermaid cell -> bug

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.