IPython notebook to slides: Reveal is not defined

坚强是说给别人听的谎言 提交于 2019-12-07 07:22:39

问题


I'm using nbconvert to make a reveal.js slideshow from my notebook. Specifically, I'm running: ipython nbconvert --to slides analysis.ipynb. This creates "analysis.slides.html", and I put "reveal.js" in the same folder. That is, I have:

  • reveal.js
    • ...
  • analysis.ipynb
  • analysis.slides.html

However, when opening "analysis.slides.html" in the browser JavaScript console, I get the following:

analysis.slides.html:1992 Uncaught ReferenceError: Reveal is not defined
analysis.slides.html:2032 Uncaught ReferenceError: Reveal is not defined
require.min.js:8 Uncaught Error: Mismatched anonymous define() module: function () {
        root.Reveal = factory();
        return root.Reveal;
    }
http://requirejs.org/docs/errors.html#mismatch

I don't get a 404 error for the line which loads reveal.js - <script src="reveal.js/js/reveal.js"></script> - so any ideas why I might be seeing the errors I am?

Thanks!


回答1:


Saw in this answer that reveal.js version 3.0.0 isn't compatible with IPython, so the solution is to use an older version, e.g. ipython nbconvert --to slides analysis.ipynb --reveal-prefix "http://cdn.jsdelivr.net/reveal.js/2.6.2".




回答2:


@harshil's answer is right on. But if you want a clean way to stay up-to-date with reveal.js and evolve with jupyter (ipython notebook), building on @Lev's answer is a bit better:

git submodule add https://github.com/hakimel/reveal.js.git
cd reveal.js
git checkout 2.6.0

And when ipython upgrades, you can just checkout that new version (tag) in your reveal.js git submodule.



来源:https://stackoverflow.com/questions/30125373/ipython-notebook-to-slides-reveal-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!