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

Commit 25e5ee5

Browse files
committedJun 22, 2014
Update to what Brandon has in octopress#1590.
imathis/octopress#1590
1 parent c1983ee commit 25e5ee5

8 files changed

+27
-207
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.DS_Store
33
.sass-cache
44
.gist-cache
5+
.code-highlighter-cache
56
.pygments-cache
67
_deploy
78
public

‎Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ gem 'rack'
55
gem 'jekyll', '~> 2.0'
66
gem 'jekyll-sitemap'
77
gem 'jekyll-page-hooks'
8+
gem 'octopress-codefence'
9+
gem 'octopress-gist'
810
gem 'liquid', '2.5.5'
911
gem 'redcarpet'
1012
gem 'compass'

‎Gemfile.lock

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ GEM
5151
rb-inotify (>= 0.9)
5252
maruku (0.7.0)
5353
mercenary (0.3.3)
54+
octopress-code-highlighter (4.0.0)
55+
colorator (~> 0.1.0)
56+
octopress-codefence (1.4.2)
57+
jekyll-page-hooks (>= 1.0.2)
58+
octopress-code-highlighter (~> 4.0.0)
59+
octopress-gist (1.2.0)
60+
octopress-code-highlighter (~> 4.0.0)
5461
parslet (1.5.0)
5562
blankslate (~> 2.0)
5663
posix-spawn (0.3.8)
@@ -94,6 +101,8 @@ DEPENDENCIES
94101
jekyll-sitemap
95102
liquid (= 2.5.5)
96103
maruku (= 0.7.0)
104+
octopress-codefence
105+
octopress-gist
97106
rack
98107
rake
99108
redcarpet

‎plugins/backtick_code_block.rb

-43
This file was deleted.

‎plugins/gist_tag.rb

-100
This file was deleted.

‎plugins/octopress_filters.rb

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,8 @@
11
# Custom filters for Octopress
22
require 'jekyll-page-hooks'
3-
require './plugins/backtick_code_block'
3+
require 'octopress-codefence'
4+
require 'octopress-gist'
45
require './plugins/raw'
5-
require 'rubypants'
6-
7-
module OctopressFilters
8-
include BacktickCodeBlock
9-
include TemplateWrapper
10-
def pre_filter(input)
11-
input = render_code_block(input)
12-
input.gsub /(<figure.+?>.+?<\/figure>)/m do
13-
safe_wrap($1)
14-
end
15-
end
16-
def post_filter(input)
17-
input = unwrap(input)
18-
RubyPants.new(input).to_html
19-
end
20-
end
21-
22-
module Jekyll
23-
class ContentFilters < PageHooks
24-
include OctopressFilters
25-
def pre_render(post)
26-
if post.ext.match('html|textile|markdown|md|haml|slim|xml')
27-
post.content = pre_filter(post.content)
28-
end
29-
end
30-
def post_render(post)
31-
if post.ext.match('html|textile|markdown|md|haml|slim|xml')
32-
post.content = post_filter(post.content)
33-
end
34-
end
35-
end
36-
end
37-
386

397
module OctopressLiquidFilters
408
include Octopress::Date

‎plugins/raw.rb

-25
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,3 @@ def unwrap(input)
1313
end
1414
end
1515
end
16-
17-
# Author: phaer, https://github.com/phaer
18-
# Source: https://gist.github.com/1020852
19-
# Description: Raw tag for jekyll. Keeps liquid from parsing text betweeen {% raw %} and {% endraw %}
20-
21-
module Jekyll
22-
class RawTag < Liquid::Block
23-
def parse(tokens)
24-
@nodelist ||= []
25-
@nodelist.clear
26-
27-
while token = tokens.shift
28-
if token =~ FullToken
29-
if block_delimiter == $1
30-
end_tag
31-
return
32-
end
33-
end
34-
@nodelist << token if not token.empty?
35-
end
36-
end
37-
end
38-
end
39-
40-
Liquid::Template.register_tag('raw', Jekyll::RawTag)

‎plugins/render_partial.rb

+13-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
#
2222
#
2323

24-
require 'pathname'
25-
require './plugins/octopress_filters'
24+
require 'jekyll-page-hooks'
2625

2726
module Jekyll
2827

2928
class RenderPartialTag < Liquid::Tag
30-
include OctopressFilters
3129
def initialize(tag_name, markup, tokens)
3230
@file = nil
3331
@raw = false
@@ -40,7 +38,7 @@ def initialize(tag_name, markup, tokens)
4038

4139
def render(context)
4240
file_dir = (context.registers[:site].source || 'source')
43-
file_path = Pathname.new(file_dir).expand_path
41+
file_path = File.expand_path(file_dir)
4442
file = file_path + @file
4543

4644
unless file.file?
@@ -52,7 +50,9 @@ def render(context)
5250
if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m
5351
contents = $1.lstrip
5452
end
55-
contents = pre_filter(contents)
53+
54+
content = parse_convertible(content, context)
55+
5656
if @raw
5757
contents
5858
else
@@ -63,6 +63,14 @@ def render(context)
6363
end
6464
end
6565
end
66+
67+
# Ensure jekyll page hooks are processed
68+
def parse_convertible(content, context)
69+
page = Jekyll::ConvertiblePartial.new(context.registers[:site], @path, content)
70+
page.render({})
71+
page.output.strip
72+
end
73+
6674
end
6775
end
6876

0 commit comments

Comments
 (0)