jonsequitur / dotnet-repl

A polyglot REPL built on .NET Interactive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

marckruzik opened this issue · comments

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