lib/octopress-escape-code.rb in octopress-escape-code-1.0.0 vs lib/octopress-escape-code.rb in octopress-escape-code-1.0.1
- old
+ new
@@ -1,27 +1,36 @@
require "octopress-escape-code/version"
-require 'jekyll-page-hooks'
+require 'octopress-hooks'
-module Jekyll
- class EscapeCode < PageHooks
- def pre_render(page)
+module Octopress
+ module EscapeCode
+
+ class EscapePage < Octopress::Hooks::Page
+ def pre_render(page)
+ if Octopress::EscapeCode.escape_enabled?(page)
+ page.content = Octopress::EscapeCode.escape(page.content, page.ext)
+ end
+ end
+ end
+
+ class EscapePost < Octopress::Hooks::Post
+ def pre_render(page)
+ if Octopress::EscapeCode.escape_enabled?(page)
+ page.content = Octopress::EscapeCode.escape(page.content, page.ext)
+ end
+ end
+ end
+
+ def self.escape_enabled?(page)
site_config = page.site.config['escape_code']
site_config = true if site_config.nil?
page_config = page.data['escape_code']
page_config = site_config if page_config.nil?
enabled = page_config
-
- if enabled
- page.content = Octopress::EscapeCode.escape(page.content, page.ext)
- end
end
- end
-end
-module Octopress
- module EscapeCode
def self.escape(content, ext)
ext = ext.downcase
content.encode!("UTF-8")
md_ext = %w{.markdown .mdown .mkdn .md .mkd .mdwn .mdtxt .mdtext}