Linux Jekyll pygments syntax highlight installation configuration

Source: Internet
Author: User

Installation:

ArchLinux:

$ sudo pacman-s python2-pygments

or through PIP installation:

$ pip Install pygments--user

I'm using an Ubuntu installation, and the command is:

sudo apt-get install python-pygments

Configuration:

Open Pygments in Jekyll's configuration article _config.yml

Pygments:true
Mardown:redcarpet

This is typically the case, but the new version needs to replace Pygments:true with highlighter:pygments

Once configured, we go to build the CSS file

Input:

Pygmentize-s default-f HTML >/root/desktop/pygments.css

Remember to fill in the path where you want to build

After the build, add the style to the Web site, and then invoke the code as follows:

<link rel= "stylesheet" href= "/css/pygments.css" >

Insert this code into the _includes/header.html call

Pygments.css need to put in your Jekyll CSS directory

Use:

The highlighted code must be placed between the label {% highlight language%} and {% endhighlight%}, where the language is the language you highlighted.

Example:

{% highlight Python%}
#use Jekyll pygments
#include <stdio.h>
JY = ' Jekyll '
print ' Use to%s '% (JY)
{% Endhighlight%}

The result of the build to the article is

#use Jekyll
JY = ' Jekyll '
print ' Use to%s '% (JY)

The style of the pygments

The default styles are Monokai, Manni, RRT, Perldoc, Borland, colorful, default, and so on.

Individuals still prefer the default style.

You can use the Python command to list Pygments currently supported styles:

>>> from pygments.styles import Style_map
>>> Style_map.keys ()
[' Monokai ', ' Manni ', ' RRT ', ' Perldoc ', ' Borland ', ' colorful ', ' Default ', ' Murphy ', ' vs ', '
' Trac ', ' Tango ', ' fruity ', ' autumn ', ' bw ', ' emacs ', ' vim ', ' pastie ', ' friendly ', ' native '

I will not intercept the style diagram, I find it, I think the default is better.

If you find a favorite style, you can upload the CSS file for that style, and the command is as follows:

$ pygmentize-s Style name-F HTML > YOUR/PATH/PYGMENTS.CSS

Basically so, will not typesetting, do this look at it!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.