我需要在LaTeX中突出显示源代码.listings
对于大多数用例而言,该软件包似乎是最佳选择,对我来说,它一直是现在.
但是,现在我需要更多的灵活性.一般来说,我正在寻找的是一个真正的词法分析器.特别是,我需要(对于自己的语言定义)来定义(并突出显示!)自己的数字样式.listings
不允许在代码中突出显示数字.但是,我需要生成这样的东西:
listings
也无法处理字符串的任意分隔符.考虑以下有效的Ruby代码:
s = %q!this is a string.!
Run Code Online (Sandbox Code Playgroud)
在这里,!
几乎可以用任何分隔符代替.
(那listings
不能处理Unicode也很烦人,但这是另一个问题.)
理想情况下,我正在寻找一个扩展,listings
这允许我提供更复杂的lexing规则.但除此之外,我也在寻找可行的替代方案.
其他线程建议使用可以产生LaTeX输出的Pygments.甚至有一个包 - texments
- 以缓解过渡.
然而,这非常缺乏功能.特别是,我对listings
样式行号,源代码行引用以及在源代码中嵌入LaTeX的可能性感兴趣(选项texcl
和mathescape
in listings
).
例如,这里是一个源代码排版集,listings
其中显示了替换程序还应提供的一些内容:
[Bit Twiddling Hacks改编的"侧身添加"]
在我总是使用RC之前,我更新到了最新的JekyllBuild(1.0.3).更新代码解析后(使用Pygments)不再起作用.我总是得到以下错误:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:162: warning: cannot close fd before spawn
?[31m Liquid Exception: No such file or directory - /bin/sh in 2012-01-17-test-post.md?[0m
Run Code Online (Sandbox Code Playgroud)
还有人遇到过这个问题吗?
我不知道红宝石,所以我不能自己调试:(
Configuration file: /Users/andrechristoga/Documents/type-theme/_config.yml
Deprecation: You appear to have pagination turned on, but you haven't included the `jekyll-paginate` gem. Ensure you have `gems: [jekyll-paginate]` in your configuration file.
Source: /Users/andrechristoga/Documents/type-theme
Destination: /Users/andrechristoga/Documents/type-theme/_site
Incremental build: disabled. Enable with --incremental
Generating...
Dependency Error: Yikes! It looks like you don't have pygments or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- …
Run Code Online (Sandbox Code Playgroud) 我在VPS上部署了我的Jekyll博客.我现在想使用Pygments突出显示添加Github风格的Markdown,但我不知道我需要编辑哪些文件以及如何编辑.
到目前为止,我配置的唯一文件是_config.yml
这样的:
1 safe: false
2 auto: false
3 server: false
4 server_port: 4000
5 baseurl: /
6 url: http://localhost:4000
7
8 source: .
9 destination: ./_site
10 plugins: ./_plugins
11
12 future: true
13 lsi: false
14 pygments: false
15 markdown: maruku
16 permalink: date
17
18 maruku:
19 use_tex: false
20 use_divs: false
21 png_engine: blahtex
22 png_dir: images/latex
23 png_url: /images/latex
24
25 rdiscount:
26 extensions: []
27
28 kramdown:
29 auto_ids: true,
30 footnote_nr: …
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
{% 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">
标记,并且代码未突出显示.
难道我做错了什么?
我使用Pygments
了很多东西,我也想在乳胶报告中使用它.我找到了Minted
与Pygments交互的包,但是一些注释和一些代码溢出了正确的边缘.我breaklines=true
过去曾使用过lstlistings ,但是我没有看到使用Minted包获得该功能的方法,任何想法?
\documentclass[10pt]{article}
\usepackage{fancyvrb}
\usepackage{minted}
\begin{document}
\begin{minted}[mathescape,
linenos,
numbersep=5pt,
frame=single,
numbersep=5pt,
xleftmargin=0,
]{python}
class Run(BaseModel):
"""
Run: unique Tool and multiple Inputs
Status:
Running => jobs are pending or runing and not all jobs have been completed
Paused => workers querying for 'Running' Runs won't get this Run until we change status again
Done => all jobs have completed and have a result_status = 'Done'
Incomplete => No results (inputs) have been associated with …
Run Code Online (Sandbox Code Playgroud) 我正在使用Jekyll将我的markdown和Pygments转换为语法高亮.
这是错误maruku显示:
Liquid error: undefined method `join' for "\n song_info = []\n for song in songs:\n song_info.append(song.name) \n":String
Run Code Online (Sandbox Code Playgroud)
标记如下:
{% highlight python %}
song_info = []
for song in songs:
song_info.append(song.name)
{% endhighlight %}
Run Code Online (Sandbox Code Playgroud)
在iPython中测试Pygments不会产生任何错误.
有任何想法吗?O(
提前致谢!
在Jekyll中工作时,是否可以在使用pygments高亮的代码部分中使用水平滚动而不是文本换行.
文件来源:
{% highlight bash %}
Full thread dump OpenJDK Client VM (19.0-b09 mixed mode, sharing):
"Attach Listener" daemon prio=10 tid=0x0a482400 nid=0x5105 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
....
{% endhighlight %}
Run Code Online (Sandbox Code Playgroud)
生成的页面(注意十六进制地址被包装而不是滚动):