跳转到主要内容

轻松将GitHub Gists嵌入到您的Pelican文章中。

项目描述

Pelican Gist Tag是一个库,可以轻松将GitHub Gists嵌入到您的Pelican博客中。

安装

要安装pelican-gist,只需

$ pip install pelican-gist

然后,将一些代码添加到您的博客配置中

PLUGINS = [
    # ...
    'pelican_gist',
    # ...
]

用法

在您的文章中,只需添加看起来像的行

[gist:id=3254906,file=brew-update-notifier.sh]

这将告诉插件在文章中插入gist id 3254906 并选择文件 brew-update-notifier.sh。生成的HTML将如下所示

<div class="gist">
    <script src='https://gist.github.com/3254906.js?file=brew-update-notifier.sh'></script>
    <noscript>
        <pre><code>#!/bin/bash ...</code></pre>
    </noscript>
</div>

如果您的gist只有一个文件,您也可以这样指定gist

[gist:id=3254906]

注意它只使用了id。生成的HTML将如下所示

<div class="gist">
    <script src='https://gist.github.com/3254906.js'></script>
    <noscript>
        <pre><code>#!/bin/bash ...</code></pre>
    </noscript>
</div>

如果指定了文件类型,则使用pygment突出显示noscript版本的代码

[gist:id=3254906,file=brew-update-notifier.sh,filetype=bash]

还支持私有gist,其中gist id看起来像 e34db4c532a6cfa1f711

设置

GIST_CACHE_ENABLED - 指定是否在磁盘上缓存gist。默认值为 True。 (可选) GIST_PYGMENTS_STYLE - pygments用于语法高亮的样式。可能的值是来自 pygments.styles.get_all_styles() 的字符串。默认值是 'default'。 (可选) GIST_PYGMENTS_LINENUM - 定义pygments是否应向渲染的HTML添加行号。默认值是 False。 (可选)

测试

使用 pip install -r requirements.txt 安装必要的依赖项。安装完成后,您可以使用: py.test 运行测试。因此,整个工作流程看起来像

$ pip install -r requrements.txt
Successfully installed pytest requests mock py
Cleaning up...
$ py.test
======================== test session starts =========================
platform darwin -- Python 2.7.6 -- pytest-2.5.1
collected 5 items

pelican_gist/test_plugin.py .....

====================== 5 passed in 0.11 seconds ======================

作者

查看GitHub上的贡献者

变更日志

  • 0.3.4 - 修复正则表达式以支持文件类型(感谢 [@andrlik](https://github.com/andrlik))

  • 0.3.3 - 支持UTF-8字符的gists

  • 0.3.2 - 添加了通用wheel支持

  • 0.3.1 - 修复了Python 3和获取gist内容的问题

  • 0.3.0 - 添加了Python 3支持

许可证

使用MIT许可证。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。

源分发

pelican-gist-0.3.4.tar.gz (6.2 kB 查看哈希值)

上传时间

构建分发

pelican_gist-0.3.4-py2.py3-none-any.whl (8.3 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面