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

Pandoc-incompatible extra meta-data from RISE Notebooks #997

Open
mfhepp opened this issue Sep 25, 2022 · 4 comments
Open

Pandoc-incompatible extra meta-data from RISE Notebooks #997

mfhepp opened this issue Sep 25, 2022 · 4 comments

Comments

@mfhepp
Copy link

mfhepp commented Sep 25, 2022

RISE is a very useful extension to Jupyter Notebook that allows presenting notebooks directly in the form of Reveal.JS slides.

Now, when converting such notebooks to Markdown, cells that directly contain RISE-specific meta-data like slide and sub_slide result in Markdown that is incompatible with Pandoc`s fenced div syntax:

Example:

This cell

 {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7f044916",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "for i in range(3):\n",
    "    print(i)"
   ]
  },

creates the following Markdown:

```python slideshow={"slide_type": "subslide"}
for i in range(3):
    print(i)
```

However, this extra meta-data slideshow={"slide_type": "subslide"} is not Pandoc Markdown syntax, and it would be more useful to translate it into something like:

```{.python slideshow="\{\"slide_type\": \"subslide\"\}"}
for i in range(3):
    print(i)
```

or, cleaner, as a Pandoc nested fenced div with attributes, like so:

``````{.slideshow slide_type="subslide"}
```{.python }
for i in range(3):
    print(i)
```
``````

A similar problem exists with RISE Speaker Notes. In the notebook, they look like so:

  {
   "cell_type": "markdown",
   "id": "786500ac",
   "metadata": {
    "slideshow": {
     "slide_type": "notes"
    }
   },
   "source": [
    "These are speaker notes.\n",
    "\n",
    "$c=\\sqrt{a^2 + b^2}$"
   ]
  },

The conversion turns them into

<!-- #region slideshow={"slide_type": "notes"} -->
These are speaker notes.

$c=\sqrt{a^2 + b^2}$
<!-- #endregion -->

While this does not break the layout, the type of the content is not accessible to Pandoc filters (at least not easily).

IMO, it would be better to represent them as

<!-- #region slideshow={"slide_type": "notes"} -->
:::{.slideshow slide_type="notes"}
These are speaker notes.

$c=\sqrt{a^2 + b^2}$
:::
<!-- #endregion -->

/CC @tarleb

@mfhepp
Copy link
Author

mfhepp commented Sep 25, 2022

For completeness, here are the Jupytext settings I used:

jupyter:
  celltoolbar: Slideshow
  jupytext:
    cell_metadata_filter: all,-trusted
    formats: ipynb,md
    notebook_metadata_filter: all
    text_representation:
      extension: .md
      format_name: markdown
      format_version: '1.3'
      jupytext_version: 1.14.0
  kernelspec:
    display_name: aih
    language: python
    name: aih
  language_info:
    codemirror_mode:
      name: ipython
      version: 3
    file_extension: .py
    mimetype: text/x-python
    name: python
    nbconvert_exporter: python
    pygments_lexer: ipython3
    version: 3.10.5
---

@mfhepp
Copy link
Author

mfhepp commented Sep 25, 2022

/CC @damianavila

@mfhepp
Copy link
Author

mfhepp commented Sep 25, 2022

Cross-referencing #66

@mwouts
Copy link
Owner

mwouts commented Oct 6, 2022

Hi @mfhepp , do I understand correctly that you are looking for Pandoc's markdown representation of notebooks?
If so, did you try to pair your notebook with the md:pandoc format, rather than with the default md format?

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

No branches or pull requests

2 participants