html - 在非本地服务器上将 reveal.js 幻灯片 (.html) [Jupyter 笔记本导出] 作为网页托管

标签 html server jupyter-notebook webpage reveal.js

我目前正在开发 Jupyter Notebook。 我设法将其导出为 reveal.js 幻灯片 (.html) 并将其托管在我的本地服务器上。我在终端中使用了以下命令行:

jupyter nbconvert <mynotebookname>.ipynb --to slides --post serve

它生成一个 <mynotebookname>.slides.html文件并在我的浏览器中打开它,我可以在其中正确浏览幻灯片(如 https://revealjs.com 上的示例所示)。

但是,如果我将此文件上传到我大学服务器上的“web”文件夹(我通常会在其中上传任何我想作为网页查看的 html 文件),我会得到一个包含笔记本内容的可滚动页面。它不会呈现与本地服务器相同的幻灯片视角。

我想将其作为网页提供,以便与其他人共享。 我错过了什么?

最佳答案

我终于设法通过使用以下命令找到了解决方案:

jupyter nbconvert <mynotebookname>.ipynb  --to slides --reveal-prefix "https://cdn.jsdelivr.net/npm/reveal.js@3.6.0 "

这样生成的 slides.html 文件将在您的浏览器中正确呈现幻灯片,无论该文件是作为独立文件在您的本地计算机上还是作为网页显示在网络服务器/github/bitbucket 上。

我不知道当不使用 --post serve 时,有必要将 reveal-prefix 指向 CDN(内容分发网络)上可用的一些 reveal.js 库。显然 --post serve 会为您做这件事。作为替代方案,也可以指向本地 reveal.js 库。

以下是帮助我找到此解决方案的一些链接。它们包含一些在将笔记本转换为幻灯片时可能有用的附加命令。

https://github.com/jupyter/nbconvert/issues/157

https://medium.com/learning-machine-learning/present-your-data-science-projects-with-jupyter-slides-75f20735eb0f

https://github.com/jupyter/nbconvert/blob/master/docs/source/usage.rst

http://www.damian.oquanta.info/posts/using-a-local-revealjs-library-with-your-ipython-slides.html

关于html - 在非本地服务器上将 reveal.js 幻灯片 (.html) [Jupyter 笔记本导出] 作为网页托管,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51772410/

相关文章:

javascript - 如何使搜索栏的结果列表可通过向上/向下箭头导航?

html - Bootstrap 导航栏 - 社交媒体右上角

html - Twitter Bootstrap 嵌套表单布局

java - 在 GlassFish 上创建 JDBC 连接池仅接受 Oracle 的一个操作数

python - 记录 T-SNE 训练?

python - Jupyter 笔记本中的自动完成功能不起作用

javascript - CSS/Bootstrap - 奇怪的 <a> 行为

c++ - 获取从 grpc 客户端传输的二进制数据

server - Informix oninit -v 坏 INFORMIXSERVER

python - 如何在 Jupyter Notebook 上查看内置函数的文档?