jupyter-book / jupyterlab-myst

Use MyST Markdown directly in Jupyter Lab
https://jupyter-book.github.io/jupyterlab-myst/
BSD 3-Clause "New" or "Revised" License
146 stars 18 forks source link

Footnotes must be defined in the same cell #86

Open agoose77 opened 1 year ago

agoose77 commented 1 year ago

Describe the bug

context When I add a footnote with some sentence [^footnote] and [^footenote]: ...

expectation I expected a wild footnote to appear

bug But instead the raw footnote markup is rendered.

Reproduce the bug

  1. Add two Markdown cells
  2. Define a footnote in cell (2), and reference it in cell (1)

List your environment

No response

rowanc1 commented 1 year ago

This is potentially going to be tricky. Right now we parse markdown in a per-block basis to speed things up a bit. Currently the footnote reference is resolved by the tokenizer (markdown-it), not the AST, which means if it isn't found the reference is interpreted as text, and we can't resolve it later.

There are a few options:

  1. we could fork the markdown-it footnotes (or have our own implementation of that that is a bit simpler);
  2. we could parse the whole notebook together every time: getting the content back to every cell is harder, and there is a bit or a performance hit
  3. we could say this is a constraint.

If we want the feature, I think that (1) would be the way to go.

zillionare commented 9 months ago

Any plan to fix this?

Here's is how I used jupyterlab-myst:

  1. create markdown file
  2. use python notedown module to convert it to *.ipynb
  3. load the converted *.ipynb in jupyterlab

I'm using vscode extension "Markdown Footnotes" (by Matt Bierner), and it will create footnotes definition at the end of the markdown file, and finally break.

Another question, even I managed to put the definition and link into one cell, the definition will just showed as tooltip. Is this by design? Would it be possible to show the definition always at the end of the cell/notebook?