使用redcarpet在jekyll中突出显示语法

使用redcarpet在jekyll中突出显示语法

本文介绍了使用redcarpet在jekyll中突出显示语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试突出显示代码,以使其适用于使用jekyll构建的简单博客.我希望能够在以markdown编写的帖子中突出显示代码,因此我启用了redcarpet作为标记语言.一切正常,代码被格式化为<pre></pre>标记,并且代码的所有各个元素都获得了相应的类.例如

I'm trying to get code highlighting to work for a simple blog built with jekyll. I want to be able to do code highlighting within posts written in markdown so I enabled redcarpet as markup language. This works all fine, the code gets formatted in <pre></pre> tags and all the various elements of the code get corresponding classes. e.g.

<span class="n">function</span>
<span class="n">saySomething</span>
<span class="p">()</span>
<span class="p">{</span>

etc.

这太棒了,但这还没有为我们提供实际的突出显示(颜色).因此,我想必须准备好一些CSS来进行复制和粘贴,这些CSS实际上可以对不同代码元素进行样式设置.还是我完全错过了什么?

This is awesome but this doesn't give us of the actual highlighting (color) yet. So I suppose there must be some css ready to copy and paste which actually does the styling of the different code elements. Or am I missing something completely?

我研究了一些突出显示代码的库,例如修饰棱镜自己在浏览器中使用javascript进行格式化.但是,由于redcarpet已经完成了格式化代码的繁重工作,因此不必再次进行格式化.

I looked into some code highlighting libraries like prettify or prism but these do their own formatting with javascript in the browser. But since redcarpet already does the heavy lifting work of formatting the code it is not necessary doing it again.

有任何提示吗?

推荐答案

您需要一些CSS魔术.使用从此处选择一个.

You need some CSS magic. Use this one or pick one from here.

这篇关于使用redcarpet在jekyll中突出显示语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 03:06