【问题标题】:A Python implementation of GitHub flavored markdown [closed]GitHub 风格的 Markdown 的 Python 实现 [关闭]
【发布时间】:2016-04-07 18:04:13
【问题描述】:

我已经搜索了一段时间,但仍然找不到任何东西。我基本上需要一个用于 Github 风格的降价的 Python 转换器,它支持语法高亮。我目前使用gfm,但是,它似乎不支持语法高亮。它不仅不给它着色,它还对代码做了一些奇怪的事情,并将它们全部放在一行中。

【问题讨论】:

  • 要求我们推荐或查找书籍、工具、软件库、教程或其他非现场资源的问题对于 Stack Overflow 来说是题外话,因为它们往往会吸引固执己见答案和垃圾邮件。取而代之的是describe the problem 以及迄今为止为解决该问题所做的工作。

标签: python markdown github-flavored-markdown


【解决方案1】:

gfm 对于 python 的另一种实现:py-gfm:

http://pythonhosted.org/py-gfm/

它为markdown 模块提供了一个扩展: https://pythonhosted.org/Markdown/

像这样使用它:

from markdown import Markdown
from mdx_gfm import GithubFlavoredMarkdownExtension

# extensions is a list, even if it's just one
md = Markdown(extensions=[GithubFlavoredMarkdownExtension()])

source = '''```python
print('Hello World')
```'''

html = md.convert(source)

另一种可能性是使用 http://prismjs.com/ 之类的 javascript 库,如果此问题得到解决,这也适用于 gfmhttps://github.com/stewart/gfm/issues/3

【讨论】:

  • 我正在尝试使用它。您是否知道一种将正在评估的 Python 变量包含在降价中的方法?类似于您拥有print("This is {myvar}")
【解决方案2】:

一个简单有效的替代方案是grip

但不处理语法高调。

【讨论】:

    猜你喜欢
    • 2015-12-02
    • 1970-01-01
    • 1970-01-01
    • 2011-12-03
    • 2011-11-25
    • 2014-10-24
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    相关资源
    最近更新 更多