无法在Github上执行Javascript

时间:2018-09-09 06:35:22

标签: javascript python github jupyter-notebook

我有以下代码将目录添加到ipython笔记本的开头。当我在计算机上的jupyter上运行单元时,我得到

enter image description here

但是当我将笔记本上载到github并选择查看笔记本时,我在第一个单元格中看到了这一点。

enter image description here

有没有一种方法可以强制此javascript行在github上像第一张图片一样运行?

2 个答案:

答案 0 :(得分:1)

“是否有一种方法可以强制此javascript行在github上像第一张图片一样运行?”

...不,Github不是为此设计的。您不能在其上运行代码。仅用于共享目的。如果要在网站上运行代码,请将其上传到CodePenJS FiddleJS Bin

答案 1 :(得分:0)

对于将来偶然发现此问题的任何人,都有解决方案。 Github不会在.ipynb文件中运行javascript扩展,但这就是nbviewer所使用的。只需将github上文件的URL输入到nbviewer主网站。

例如,检查内容javascript扩展表(第一个单元格)如何在nbviewer上运行

https://nbviewer.jupyter.org/github/lukepolson/Python-Self-Learning/blob/master/Matplotlib_2-Additional_Features.ipynb

但不在github

https://github.com/lukepolson/Python-Self-Learning/blob/master/Matplotlib_2-Additional_Features.ipynb