【问题标题】:How to embed code from Github repository like what you can do with a gist?如何从 Github 存储库嵌入代码,就像你可以用 gist 做的那样?
【发布时间】:2020-04-16 20:40:09
【问题描述】:

我希望能够将来自我的存储库的文件中的代码嵌入到我的 github 页面中。 我发现这对 gists 非常有用,但我找不到存储库文件的方法。

举个例子:

有人有解决方案吗? 这可能是 github 增强功能吗?或者这没有意义?

【问题讨论】:

    标签: github embed code-snippets gist


    【解决方案1】:

    在 gist URL 的末尾添加 .js,并将其包含在 <script> 中效果很好

    用这段代码sn-p证明(点击“运行代码sn-p”):

    <div>
      Check out this source code:
      <br>
      <script src="https://gist.github.com/DGrv/771dd2b1f9c05d8fcf17f3ff84bfc1f3.js"></script>
    </div>

    但是,这仅适用于 gist,不适用于 Github 文件

    【讨论】:

    • 谢谢。我也可以完成这项工作,但实际上我希望使用 Github 文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    • 1970-01-01
    • 1970-01-01
    • 2015-01-08
    • 2013-01-10
    • 1970-01-01
    • 2010-11-13
    相关资源
    最近更新 更多