Sha256: 7809591a4d18441ee9730fb7584497175552f9c20ed629094ef789f1ca4cf8b6
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require "jekyll" require "htmlbeautifier" require "htmlcompressor" JEKYLL_CONFIG = Jekyll.configuration({}) module Jekyll module Tidy def self.exclude?(path) res = false exclude = JEKYLL_CONFIG['jekyll_tidy'] && JEKYLL_CONFIG['jekyll_tidy']['exclude'] if exclude res = exclude.to_a.include? path end return res end def self.compress_html? JEKYLL_CONFIG['jekyll_tidy'] && JEKYLL_CONFIG['jekyll_tidy']['compress_html'] end def self.output_clean(output) if compress_html? compressor = HtmlCompressor::Compressor.new return compressor.compress output else return HtmlBeautifier.beautify output end end end end Jekyll::Hooks.register :posts, :post_render do |post| unless Jekyll::Tidy::exclude?(post.path) post.output = Jekyll::Tidy::output_clean(post.output) end end Jekyll::Hooks.register :pages, :post_render do |page| unless Jekyll::Tidy::exclude?(page.path) page.output = Jekyll::Tidy::output_clean(page.output) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-tidy-0.0.1 | lib/jekyll/tidy.rb |