【发布时间】:2014-08-18 16:50:16
【问题描述】:
我创建了一个pygments样式,使用了和xcode一样的颜色,命名为xcode.py:
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic
class xcodeStyle(Style):
default_style = ""
styles = {
Text: '#000000',
Comment: '#008426',
String: '#D92823',
Number: '#2F2ECF',
Keyword: '#C22A9C',
Name.Class: '#753EA3'
}
我尝试将它放在/Library/Python/2.7/site-packages/pygments/styles 中,但是当我列出可用样式时,
from pygments.styles import get_all_styles
styles = list(get_all_styles())
print styles
我的风格没有得到认可。任何想法为什么?
【问题讨论】:
-
您解决了这个问题吗?我也遇到了同样的问题。
-
是和不是。我最终浏览了 BitBucket 上的源代码,并找到了内置的 xcode 样式。所以我简单地安装了源代码(v2.0 Beta),就是这样。我刚刚检查过,在终端中运行
pygmentize -L时,甚至没有列出新样式。所以我猜 pygmentize 不知道它存在,但是当我使用它的风格时。我在带有 minted 包的 LaTex 中使用它,它就像一个魅力 -
我意识到我已经用 Python 2 安装了 Pygments,所以我在 Python 3 目录中安装的样式自然会被忽略,因为 Python 2
pygmentize首先出现在 PATH 中。