【问题标题】:Include code from GitHub as code block in GitBook将来自 GitHub 的代码作为代码块包含在 GitBook 中
【发布时间】:2017-10-09 19:18:40
【问题描述】:

如何在 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函数。

【问题讨论】:

    标签: javascript github gitbook


    【解决方案1】:

    只需将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 installgitbook serve),但它在 GitBooks 上不适合我,所以我提交了一个问题 herehere

    (证明它在本地工作)

    代表 gitbook-plugin-github-embed 为他们弃用的代码道歉!

    【讨论】:

    • 谢谢!我试过这个(在 Mac 上使用 GitBook 编辑器),但没有出现。在控制台中显示:“错误:文档模式尚不支持 HTML 和模板标签。”我想我只需要等到它完全开发出来。我还尝试了 JavaScript 插件(例如菜单等),但它们中的大多数在 Safari、Firefox、Chrome 等上都无法始终如一地工作。
    猜你喜欢
    • 2019-03-05
    • 2021-05-11
    • 2014-11-07
    • 2018-07-15
    • 1970-01-01
    • 2014-05-19
    • 2012-07-30
    • 2016-06-21
    • 1970-01-01
    相关资源
    最近更新 更多