Skip to content
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

Add support for languages other than python #25

Closed
prudhomm opened this issue Sep 20, 2023 · 9 comments · Fixed by #29
Closed

Add support for languages other than python #25

prudhomm opened this issue Sep 20, 2023 · 9 comments · Fixed by #29

Comments

@prudhomm
Copy link
Contributor

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
prudhomm added a commit to feelpp/asciidoctor-jupyter that referenced this issue Sep 20, 2023
@ggrossetie
Copy link
Contributor

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
Copy link
Contributor

@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
Copy link
Contributor

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
Copy link
Contributor

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

{
  "metadata": {
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3",
      "language": "python"
    }
  }
}

@prudhomm
Copy link
Contributor Author

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

@prudhomm
Copy link
Contributor Author

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

@ggrossetie
Copy link
Contributor

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

This should be fixed by #28

@ggrossetie
Copy link
Contributor

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

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

  • :jupyter-language-name: -> metadata.language_info.name
  • :jupyter-language-version: -> metadata.language_info.version

I think we should introduce two additional attributes:

  • :jupyter-kernel-name: -> metadata.kernelspec.name
  • :jupyter-kernel-language: -> metadata.kernelspec.language

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
Copy link
Contributor Author

this seems to be a good plan !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants