Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kramdown/Rouge doesn't highlight syntax?

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 Answers

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

like image 173
XueYu Avatar answered Nov 03 '25 01:11

XueYu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!