在Jekyll中显示文件名,并带有突出显示的代码 [英] Showing file name in Jekyll with Pygments code highlight
问题描述
在已知位置突出显示标准文件时,我想将文件名放在代码块中;最好在顶部.一个假设的例子是
When highlighting a standard file at a known location I'd like to put the file name in the code block; preferably at the top. A hypothetical example would be
{% highlight apache show_filename=/etc/httpd/conf/httpd.conf %}
.... the file contents ....
{% endhighlight %}
然后将渲染带有前缀文件名的代码块.有没有办法做到这一点?
which would then render a code block with a filename prefixed. Is there a way to accomplish this?
推荐答案
您可以简单地使用漂亮的html5 figure 标签.
You can simply use the nice html5 figure tag.
" HTML元素表示独立的内容,通常带有标题(figcaption),通常被称为单个单元.尽管它与主流相关,但其位置与主流无关通常,这是正文中引用的图像,插图,图表,代码段或架构,但是可以将其移动到另一页或附录中而不会影响主流程. " MDN> html>图形
"The HTML Element represents self-contained content, frequently with a caption (figcaption), and is typically referenced as a single unit. While it is related to the main flow, its position is independent of the main flow. Usually this is an image, an illustration, a diagram, a code snippet, or a schema that is referenced in the main text, but that can be moved to another page or to an appendix without affecting the main flow." MDN > html > figure
<figure>
<figcaption>File: folderName/fileName.rb</figcaption>
{% highlight ruby %}
def print_hi(name)
puts "Hi, #{name}"
end
{% endhighlight %}
</figure>
这篇关于在Jekyll中显示文件名,并带有突出显示的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!