2

I've been building a small personal site with Jekyll and Rouge isn't highlighting my syntax. Can anyone help explain why?

_config.yml:

title: My Name
author: My Name
url: "http://myname.com"
baseurl: ""

permalink: /projects/:title

markdown: kramdown
higlighter: rouge

tracking_id: Google Tracking ID

sass:
    style: compressed
    sass_dir: _sass

Page with syntax highlighting issues:

---
layout: post
title: Python for...Wine Analysis?
blurb: tbd
tags:
    - machine learning
    - python
    - pandas
    - scikit-learn
---

## Imports

```python

import pandas as pd
from pandas import DataFrame, Series
from patsy import dmatrices
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
from sklearn import tree
import statsmodels.api as sm
import os

%pylab inline
```

I've followed a couple tutorials, but none have seemed to help. Here's what it ends up looking like:

Image

1 Answers1

2

I used some time to figure out this.

  1. install rouge first

gem install rouge

  1. set up in _config.yml file:

highlighter: rouge

  1. add css file

rougify help style

you can run the command in Terminal and see all the provided css templates.

Say you want to use github template, you do this:

rougify style github > /path/to/css/file.css

You can also make scss file.

  1. add this css file to your header.

<link href="path-to-syntax-highlighter-stylesheet" rel="stylesheet">

If you want more customization, check → Add Syntax Highlighting to your Jekyll site with Rouge

XueYu
  • 2,355
  • 29
  • 33
  • steps 1 and 2 did it for me. Just as an addition: when you have a more "exotic" formats like jsx that were not included in the first versions of rouge, you can gem install a newer rouge and edit Gemfile.lock to actually force use (in my case: 3.0.0 instead of 1.11.0). It works like charm then – Sebastian Rothbucher Sep 23 '17 at 15:34