How to add some classes in HTML file after rendering with Jekyll

Viewed 338

I use Jekyll and I need to add classes in a HTML tags after rendering Markdown to HTML.

I could use jQuery or simple JavaScript for this task but I would like to understand how hooks work with Jekyll.

I wrote this in a Gemfile:

Jekyll::Hooks.register :pages, :post_render do |post|
    # here I need write something with Ruby language
end

Only a few pages from a collection are affected by this: How can I do it?

I would like to add this:

class="line-numbers"

For all pre tags in the HTML rendered file.

2 Answers
Related