使用Jekyll和pygments突出显示不起作用

den*_*min 28 pygments jekyll

我想和jekyll一起使用pygments

我有以下代码:

{% highlight java %}
NullPointerException at org.springframework.core.GenericTypeResolver.getTypeVariableMap
{% endhighlight %}
Run Code Online (Sandbox Code Playgroud)

当我生成我的网站时jekyll --pygments,html结果是:

<div>
  <pre><code class="java">NullPointerException at org.springframework.core.GenericTypeResolver.getTypeVariableMap</code>
  </pre>
</div>
Run Code Online (Sandbox Code Playgroud)

在此html输出中没有预期<span class="n"><span class="s2">标记,并且代码未突出显示.

难道我做错了什么?

wna*_*nto 38

您需要生成css才能突出显示.

$ pygmentize -S default -f html > css/pygments/default.css
Run Code Online (Sandbox Code Playgroud)

  • +10 - 这应该在Jekyll文档中更加突出(存在?) (20认同)
  • 请注意,您还必须告诉您的Jekyll模板获取新的CSS文件 - 在我的情况下,通过编辑_layouts/default.html(Jekyll bootstrap). (5认同)
  • 我刚刚在[jekyll install wiki](https://github.com/mojombo/jekyll/wiki/Install)中添加了一些关于如何在安装后实际使用Pygments的注释.希望它能让事情变得清晰起来. (5认同)