Skip to content
This repository has been archived by the owner on Jun 21, 2020. It is now read-only.

Commit

Permalink
Update to what Brandon has in octopress#1590.
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Jun 22, 2014
1 parent c1983ee commit 25e5ee5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 207 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
.sass-cache
.gist-cache
.code-highlighter-cache
.pygments-cache
_deploy
public
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ gem 'rack'
gem 'jekyll', '~> 2.0'
gem 'jekyll-sitemap'
gem 'jekyll-page-hooks'
gem 'octopress-codefence'
gem 'octopress-gist'
gem 'liquid', '2.5.5'
gem 'redcarpet'
gem 'compass'
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ GEM
rb-inotify (>= 0.9)
maruku (0.7.0)
mercenary (0.3.3)
octopress-code-highlighter (4.0.0)
colorator (~> 0.1.0)
octopress-codefence (1.4.2)
jekyll-page-hooks (>= 1.0.2)
octopress-code-highlighter (~> 4.0.0)
octopress-gist (1.2.0)
octopress-code-highlighter (~> 4.0.0)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.8)
Expand Down Expand Up @@ -94,6 +101,8 @@ DEPENDENCIES
jekyll-sitemap
liquid (= 2.5.5)
maruku (= 0.7.0)
octopress-codefence
octopress-gist
rack
rake
redcarpet
Expand Down
43 changes: 0 additions & 43 deletions plugins/backtick_code_block.rb

This file was deleted.

100 changes: 0 additions & 100 deletions plugins/gist_tag.rb

This file was deleted.

36 changes: 2 additions & 34 deletions plugins/octopress_filters.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
# Custom filters for Octopress
require 'jekyll-page-hooks'
require './plugins/backtick_code_block'
require 'octopress-codefence'
require 'octopress-gist'
require './plugins/raw'
require 'rubypants'

module OctopressFilters
include BacktickCodeBlock
include TemplateWrapper
def pre_filter(input)
input = render_code_block(input)
input.gsub /(<figure.+?>.+?<\/figure>)/m do
safe_wrap($1)
end
end
def post_filter(input)
input = unwrap(input)
RubyPants.new(input).to_html
end
end

module Jekyll
class ContentFilters < PageHooks
include OctopressFilters
def pre_render(post)
if post.ext.match('html|textile|markdown|md|haml|slim|xml')
post.content = pre_filter(post.content)
end
end
def post_render(post)
if post.ext.match('html|textile|markdown|md|haml|slim|xml')
post.content = post_filter(post.content)
end
end
end
end


module OctopressLiquidFilters
include Octopress::Date
Expand Down
25 changes: 0 additions & 25 deletions plugins/raw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,3 @@ def unwrap(input)
end
end
end

# Author: phaer, https://github.com/phaer
# Source: https://gist.github.com/1020852
# Description: Raw tag for jekyll. Keeps liquid from parsing text betweeen {% raw %} and {% endraw %}

module Jekyll
class RawTag < Liquid::Block
def parse(tokens)
@nodelist ||= []
@nodelist.clear

while token = tokens.shift
if token =~ FullToken
if block_delimiter == $1
end_tag
return
end
end
@nodelist << token if not token.empty?
end
end
end
end

Liquid::Template.register_tag('raw', Jekyll::RawTag)
18 changes: 13 additions & 5 deletions plugins/render_partial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
#
#

require 'pathname'
require './plugins/octopress_filters'
require 'jekyll-page-hooks'

module Jekyll

class RenderPartialTag < Liquid::Tag
include OctopressFilters
def initialize(tag_name, markup, tokens)
@file = nil
@raw = false
Expand All @@ -40,7 +38,7 @@ def initialize(tag_name, markup, tokens)

def render(context)
file_dir = (context.registers[:site].source || 'source')
file_path = Pathname.new(file_dir).expand_path
file_path = File.expand_path(file_dir)
file = file_path + @file

unless file.file?
Expand All @@ -52,7 +50,9 @@ def render(context)
if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m
contents = $1.lstrip
end
contents = pre_filter(contents)

content = parse_convertible(content, context)

if @raw
contents
else
Expand All @@ -63,6 +63,14 @@ def render(context)
end
end
end

# Ensure jekyll page hooks are processed
def parse_convertible(content, context)
page = Jekyll::ConvertiblePartial.new(context.registers[:site], @path, content)
page.render({})
page.output.strip
end

end
end

Expand Down

0 comments on commit 25e5ee5

Please sign in to comment.