neo4j-documentation / asciidoctor-jupyter

A Jupyter converter for Asciidoctor.js. Write your Notebook in AsciiDoc!
16 stars 1 forks source link

Add support for languages other than python #25

Closed prudhomm closed 1 year ago

prudhomm commented 1 year ago

Jupyter supports various kernels for different languages eg C++ Julia, Rust ... it would nice to generate code cells automatically when we have

[source,cpp]
----
int i=1;
----

here is an example https://deploy-preview-9--cours-cpp-incandescent-llama-63edb8.netlify.app/cours-cpp/cours1/#_les_flux_dentr%C3%A9essorties

you can. download the jupyter file asciidoctor-jupyter does not generate a code cell but rather a markdown cell with code. I generated it by hand after and show the image below

Screenshot 2023-09-20 at 08 28 28
ggrossetie commented 1 year ago

Jupyter supports various kernels for different languages eg C++ Julia, Rust ...

Is it configurable? I wonder if we should make it configurable? If the kernel is not available/enabled then I guess it would be preferable to generate a Markdown cell?

ggrossetie commented 1 year ago

@prudhomm could you please provide a notebook which uses a Jupyter kernel for the C++ programming language? I want to check the value of the metadata field in the ipynb file.

Currently, we are using:

{
  "metadata":{
    "language_info": {
      "name": "python",
      "version": "3.9.1"
    }
  }
}
ggrossetie commented 1 year ago

I found an example file at: https://github.com/jupyter-xeus/xeus-cling

{
  "metadata": {
    "kernelspec": {
      "name": "xcpp17",
      "display_name": "C++17",
      "language": "C++17"
    },
    "language_info": {
      "codemirror_mode": "text/x-c++src",
      "file_extension": ".cpp",
      "mimetype": "text/x-c++src",
      "name": "c++",
      "version": "17"
    }
  }
}
ggrossetie commented 1 year ago

By default, we should probably set the kernelspec as follows:


{
  "metadata": {
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3",
      "language": "python"
    }
  }
}
prudhomm commented 1 year ago

Great you found the information. Do you need something else?

prudhomm commented 1 year ago

@ggrossetie le notebook is ok under vscode but not in jupyter an extra space is probably needly after/before code blocks

ggrossetie commented 1 year ago

notebook is ok under vscode but not in jupyter an extra space is probably needly after/before code blocks

This should be fixed by https://github.com/neo4j-documentation/asciidoctor-jupyter/pull/28

ggrossetie commented 1 year ago

Great you found the information. Do you need something else?

We need to decide how to configure the kernel. Currently, we are using:

I think we should introduce two additional attributes:

We should probably use :jupyter-language-name: to decide which code blocks we should convert to code cells. For backward compatiblity, if :jupyter-language-name: is equals to python, we will convert both python and py code blocks to code cells.

prudhomm commented 1 year ago

this seems to be a good plan !