如何在 GitBook 中显示这样的原始代码?
https://raw.githubusercontent.com/luyongxu/SignalPlot/master/Code/1.016%20Asset%20Bubbles.R
我认为这与以下内容有关:
Reading code from GitHub as text (raw) in a web page
但是我不知道如何调用主文档中的JavaScript函数。
最佳答案
只需添加一个 book.json
文件到您的 GitBook。将其粘贴到其中:
{
"plugins": ["github-embed"]
}
现在只需在您的页面中放置类似的内容:
{% github_embed "https://github.com/v5analytics/gitbook-plugin-github-embed/blob/1cd16ac/index.js#L3-L8" %}{% endgithub_embed %}
就是这么简单!
Here's some documentation.
注意:我让它在本地工作(使用
gitbook install
和 gitbook serve
),但它在 GitBooks 上对我不起作用,所以我提交了一个问题 here和 here .(证明它在本地工作)
代表 gitbook-plugin-github-embed 为他们弃用的代码道歉!
关于javascript - 将来自 GitHub 的代码作为代码块包含在 GitBook 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43904375/