jkitchin / ox-ipynb

org-mode exporter to Jupyter notebooks
170 stars 39 forks source link

Export of citation fails #45

Open hatlafax opened 1 year ago

hatlafax commented 1 year ago

Exporting a org-mode document to ipynb fails with the following error message: Unable to resolve link "citeproc_bib_item_1"

I have an org-mode document with citations and jupyter-python code blocks that I wish to export to html, latex and ipynb. Export to html and latex works fine and is used routinely. Now the export to ipynb is new and is not working perfectly. My procedure is as follows: I have first exported the org document to org via org-ref as I always do for html export and get something like is shown below. Then I either use the usual html exporter which works fine or the ipynb exporter.

First the original document:

+title: PyTorch Test

+category: PyTorch Test

+include: ../../OptionsPreamble.org

+include: ../../LatexPreamble.org

+include: ../../HtmlPreamble.org

+include: ../../ThemeDakrone.org

+startup: inlineimages

+property: header-args:jupyter-python :session jupyter-python-3a884c28cceba85e17d10f6dce2d8df7

+begin_src jupyter-python

print("Hello")

+end_src

+RESULTS:

:RESULTS: Hello :END:

+csl-style: apa-numeric-superscript-brackets.csl

+csl-locale: en-US

+begin_export org

bibliographystyle:apacite

+end_export

bibliography:../../../bibliography/bibliography.bib

Secondly, the temporary buffer after using org-ref export to Org buffer

+title: PyTorch Test

+category: PyTorch Test

+latex_class: apa7

+latex_class_options: [a4paper, biblatex]

+latex_header: \usepackage{physics,amsmath}

...

+startup: inlineimages

+property: header-args:jupyter-python :session jupyter-python-3a884c28cceba85e17d10f6dce2d8df7

Learning the basics of PyTorch^{[[[citeproc_bib_item_1][1]]]}.

+begin_src jupyter-python

print("Hello")

+end_src

+csl-style: apa-numeric-superscript-brackets.csl

+csl-locale: en-US

bibliographystyle:apacite <>1. PyTorch contributors. (2022). /PyTorch - An open source machine learning framework that accelerates the path from research prototyping to production deployment./ https://pytorch.org/

When I now export this temporary buffer with ox-ipynb I get the error message. Do I something wrong or is this expected/known behavior?

An additional problem that I have with the export to the temporary buffer is that the org-babel result section is missing. Is there a simple solution?

Any help is appreciated.

jkitchin commented 1 year ago

I guess that could be expected. the exporter has some challenges for an example like this. I think what happens is it is trying to export the string containing that link to markdown in isolation (i.e. it does not know about the target at the end. That is a limitation of the exporter that can't be easily fixed. A solution might be to (setq org-export-with-broken-links t) which should allow it to work, although perhaps the links will not work in the notebook.

hatlafax commented 1 year ago

org-export-with-broken-links did work for me. At least now I got the bibliography at the end of the document. The cite links do not work as expected. Thanks for taking time.