jekyll-reloaded 0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/History.txt +321 -0
- data/LICENSE +21 -0
- data/README.textile +41 -0
- data/Rakefile +161 -0
- data/bin/jekyll +289 -0
- data/cucumber.yml +1 -0
- data/features/create_sites.feature +112 -0
- data/features/embed_filters.feature +60 -0
- data/features/markdown.feature +30 -0
- data/features/pagination.feature +27 -0
- data/features/permalinks.feature +65 -0
- data/features/post_data.feature +153 -0
- data/features/site_configuration.feature +145 -0
- data/features/site_data.feature +82 -0
- data/features/step_definitions/jekyll_steps.rb +145 -0
- data/features/support/env.rb +19 -0
- data/jekyll.gemspec +146 -0
- data/lib/guard/jekyll.rb +57 -0
- data/lib/jekyll/converter.rb +50 -0
- data/lib/jekyll/converters/identity.rb +22 -0
- data/lib/jekyll/converters/markdown.rb +125 -0
- data/lib/jekyll/converters/textile.rb +50 -0
- data/lib/jekyll/convertible.rb +116 -0
- data/lib/jekyll/core_ext.rb +52 -0
- data/lib/jekyll/errors.rb +6 -0
- data/lib/jekyll/filters.rb +118 -0
- data/lib/jekyll/generator.rb +7 -0
- data/lib/jekyll/generators/pagination.rb +113 -0
- data/lib/jekyll/layout.rb +51 -0
- data/lib/jekyll/live_site.rb +216 -0
- data/lib/jekyll/migrators/csv.rb +26 -0
- data/lib/jekyll/migrators/drupal.rb +103 -0
- data/lib/jekyll/migrators/enki.rb +49 -0
- data/lib/jekyll/migrators/joomla.rb +53 -0
- data/lib/jekyll/migrators/marley.rb +52 -0
- data/lib/jekyll/migrators/mephisto.rb +84 -0
- data/lib/jekyll/migrators/mt.rb +86 -0
- data/lib/jekyll/migrators/posterous.rb +67 -0
- data/lib/jekyll/migrators/rss.rb +47 -0
- data/lib/jekyll/migrators/textpattern.rb +58 -0
- data/lib/jekyll/migrators/tumblr.rb +195 -0
- data/lib/jekyll/migrators/typo.rb +51 -0
- data/lib/jekyll/migrators/wordpress.rb +294 -0
- data/lib/jekyll/migrators/wordpressdotcom.rb +70 -0
- data/lib/jekyll/page.rb +160 -0
- data/lib/jekyll/plugin.rb +77 -0
- data/lib/jekyll/post.rb +262 -0
- data/lib/jekyll/site.rb +339 -0
- data/lib/jekyll/static_file.rb +77 -0
- data/lib/jekyll/tags/highlight.rb +118 -0
- data/lib/jekyll/tags/include.rb +37 -0
- data/lib/jekyll/tags/post_url.rb +38 -0
- data/lib/jekyll.rb +134 -0
- data/test/helper.rb +34 -0
- data/test/source/.htaccess +8 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/simple.html +1 -0
- data/test/source/_posts/2008-02-02-not-published.textile +8 -0
- data/test/source/_posts/2008-02-02-published.textile +8 -0
- data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
- data/test/source/_posts/2008-11-21-complex.textile +8 -0
- data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
- data/test/source/_posts/2008-12-13-include.markdown +8 -0
- data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
- data/test/source/_posts/2009-01-27-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-category.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
- data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
- data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
- data/test/source/_posts/2009-05-18-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-tags.textile +9 -0
- data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
- data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
- data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
- data/test/source/_posts/2010-01-09-date-override.textile +7 -0
- data/test/source/_posts/2010-01-09-time-override.textile +7 -0
- data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
- data/test/source/_posts/2010-01-16-override-data.textile +4 -0
- data/test/source/_posts/2011-04-12-md-extension.md +7 -0
- data/test/source/_posts/2011-04-12-text-extension.text +0 -0
- data/test/source/about.html +6 -0
- data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
- data/test/source/contacts.html +5 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/deal.with.dots.html +7 -0
- data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
- data/test/source/index.html +22 -0
- data/test/source/sitemap.xml +32 -0
- data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
- data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
- data/test/suite.rb +11 -0
- data/test/test_configuration.rb +29 -0
- data/test/test_core_ext.rb +66 -0
- data/test/test_filters.rb +62 -0
- data/test/test_generated_site.rb +72 -0
- data/test/test_kramdown.rb +23 -0
- data/test/test_page.rb +117 -0
- data/test/test_pager.rb +113 -0
- data/test/test_post.rb +450 -0
- data/test/test_rdiscount.rb +18 -0
- data/test/test_redcarpet.rb +21 -0
- data/test/test_redcloth.rb +86 -0
- data/test/test_site.rb +220 -0
- data/test/test_tags.rb +201 -0
- metadata +332 -0
data/jekyll.gemspec
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'jekyll-reloaded'
|
4
|
+
s.version = '0.12'
|
5
|
+
|
6
|
+
s.summary = "Mislav's fork of Jekyll"
|
7
|
+
s.description = "Jekyll is a simple, blog aware, static site generator."
|
8
|
+
|
9
|
+
s.authors = ["Tom Preston-Werner", "Mislav Marohnić"]
|
10
|
+
s.email = 'mislav.marohnic@gmail.com'
|
11
|
+
s.homepage = 'https://github.com/mislav/jekyll/tree/reloaded'
|
12
|
+
|
13
|
+
# s.executables = ["jekyll"]
|
14
|
+
|
15
|
+
s.add_runtime_dependency('liquid', "~> 2.3")
|
16
|
+
s.add_runtime_dependency('classifier', "~> 1.3")
|
17
|
+
s.add_runtime_dependency('directory_watcher', "~> 1.1")
|
18
|
+
s.add_runtime_dependency('maruku', "~> 0.5")
|
19
|
+
s.add_runtime_dependency('kramdown', "~> 0.13")
|
20
|
+
s.add_runtime_dependency('pygments.rb', "~> 0.2.4")
|
21
|
+
|
22
|
+
s.add_development_dependency('rake', "~> 0.9")
|
23
|
+
s.add_development_dependency('rdoc', "~> 3.11")
|
24
|
+
s.add_development_dependency('redgreen', "~> 1.2")
|
25
|
+
s.add_development_dependency('shoulda', "~> 2.11")
|
26
|
+
s.add_development_dependency('rr', "~> 1.0")
|
27
|
+
s.add_development_dependency('cucumber', "1.1")
|
28
|
+
s.add_development_dependency('RedCloth', "~> 4.2")
|
29
|
+
s.add_development_dependency('rdiscount', "~> 1.6")
|
30
|
+
s.add_development_dependency('redcarpet', "~> 1.9")
|
31
|
+
|
32
|
+
# = MANIFEST =
|
33
|
+
s.files = %w[
|
34
|
+
Gemfile
|
35
|
+
History.txt
|
36
|
+
LICENSE
|
37
|
+
README.textile
|
38
|
+
Rakefile
|
39
|
+
bin/jekyll
|
40
|
+
cucumber.yml
|
41
|
+
features/create_sites.feature
|
42
|
+
features/embed_filters.feature
|
43
|
+
features/markdown.feature
|
44
|
+
features/pagination.feature
|
45
|
+
features/permalinks.feature
|
46
|
+
features/post_data.feature
|
47
|
+
features/site_configuration.feature
|
48
|
+
features/site_data.feature
|
49
|
+
features/step_definitions/jekyll_steps.rb
|
50
|
+
features/support/env.rb
|
51
|
+
jekyll.gemspec
|
52
|
+
lib/guard/jekyll.rb
|
53
|
+
lib/jekyll.rb
|
54
|
+
lib/jekyll/converter.rb
|
55
|
+
lib/jekyll/converters/identity.rb
|
56
|
+
lib/jekyll/converters/markdown.rb
|
57
|
+
lib/jekyll/converters/textile.rb
|
58
|
+
lib/jekyll/convertible.rb
|
59
|
+
lib/jekyll/core_ext.rb
|
60
|
+
lib/jekyll/errors.rb
|
61
|
+
lib/jekyll/filters.rb
|
62
|
+
lib/jekyll/generator.rb
|
63
|
+
lib/jekyll/generators/pagination.rb
|
64
|
+
lib/jekyll/layout.rb
|
65
|
+
lib/jekyll/live_site.rb
|
66
|
+
lib/jekyll/migrators/csv.rb
|
67
|
+
lib/jekyll/migrators/drupal.rb
|
68
|
+
lib/jekyll/migrators/enki.rb
|
69
|
+
lib/jekyll/migrators/joomla.rb
|
70
|
+
lib/jekyll/migrators/marley.rb
|
71
|
+
lib/jekyll/migrators/mephisto.rb
|
72
|
+
lib/jekyll/migrators/mt.rb
|
73
|
+
lib/jekyll/migrators/posterous.rb
|
74
|
+
lib/jekyll/migrators/rss.rb
|
75
|
+
lib/jekyll/migrators/textpattern.rb
|
76
|
+
lib/jekyll/migrators/tumblr.rb
|
77
|
+
lib/jekyll/migrators/typo.rb
|
78
|
+
lib/jekyll/migrators/wordpress.rb
|
79
|
+
lib/jekyll/migrators/wordpressdotcom.rb
|
80
|
+
lib/jekyll/page.rb
|
81
|
+
lib/jekyll/plugin.rb
|
82
|
+
lib/jekyll/post.rb
|
83
|
+
lib/jekyll/site.rb
|
84
|
+
lib/jekyll/static_file.rb
|
85
|
+
lib/jekyll/tags/highlight.rb
|
86
|
+
lib/jekyll/tags/include.rb
|
87
|
+
lib/jekyll/tags/post_url.rb
|
88
|
+
test/helper.rb
|
89
|
+
test/source/.htaccess
|
90
|
+
test/source/_includes/sig.markdown
|
91
|
+
test/source/_layouts/default.html
|
92
|
+
test/source/_layouts/simple.html
|
93
|
+
test/source/_posts/2008-02-02-not-published.textile
|
94
|
+
test/source/_posts/2008-02-02-published.textile
|
95
|
+
test/source/_posts/2008-10-18-foo-bar.textile
|
96
|
+
test/source/_posts/2008-11-21-complex.textile
|
97
|
+
test/source/_posts/2008-12-03-permalinked-post.textile
|
98
|
+
test/source/_posts/2008-12-13-include.markdown
|
99
|
+
test/source/_posts/2009-01-27-array-categories.textile
|
100
|
+
test/source/_posts/2009-01-27-categories.textile
|
101
|
+
test/source/_posts/2009-01-27-category.textile
|
102
|
+
test/source/_posts/2009-01-27-empty-categories.textile
|
103
|
+
test/source/_posts/2009-01-27-empty-category.textile
|
104
|
+
test/source/_posts/2009-03-12-hash-#1.markdown
|
105
|
+
test/source/_posts/2009-05-18-empty-tag.textile
|
106
|
+
test/source/_posts/2009-05-18-empty-tags.textile
|
107
|
+
test/source/_posts/2009-05-18-tag.textile
|
108
|
+
test/source/_posts/2009-05-18-tags.textile
|
109
|
+
test/source/_posts/2009-06-22-empty-yaml.textile
|
110
|
+
test/source/_posts/2009-06-22-no-yaml.textile
|
111
|
+
test/source/_posts/2010-01-08-triple-dash.markdown
|
112
|
+
test/source/_posts/2010-01-09-date-override.textile
|
113
|
+
test/source/_posts/2010-01-09-time-override.textile
|
114
|
+
test/source/_posts/2010-01-09-timezone-override.textile
|
115
|
+
test/source/_posts/2010-01-16-override-data.textile
|
116
|
+
test/source/_posts/2011-04-12-md-extension.md
|
117
|
+
test/source/_posts/2011-04-12-text-extension.text
|
118
|
+
test/source/about.html
|
119
|
+
test/source/category/_posts/2008-9-23-categories.textile
|
120
|
+
test/source/contacts.html
|
121
|
+
test/source/css/screen.css
|
122
|
+
test/source/deal.with.dots.html
|
123
|
+
test/source/foo/_posts/bar/2008-12-12-topical-post.textile
|
124
|
+
test/source/index.html
|
125
|
+
test/source/sitemap.xml
|
126
|
+
test/source/win/_posts/2009-05-24-yaml-linebreak.markdown
|
127
|
+
test/source/z_category/_posts/2008-9-23-categories.textile
|
128
|
+
test/suite.rb
|
129
|
+
test/test_configuration.rb
|
130
|
+
test/test_core_ext.rb
|
131
|
+
test/test_filters.rb
|
132
|
+
test/test_generated_site.rb
|
133
|
+
test/test_kramdown.rb
|
134
|
+
test/test_page.rb
|
135
|
+
test/test_pager.rb
|
136
|
+
test/test_post.rb
|
137
|
+
test/test_rdiscount.rb
|
138
|
+
test/test_redcarpet.rb
|
139
|
+
test/test_redcloth.rb
|
140
|
+
test/test_site.rb
|
141
|
+
test/test_tags.rb
|
142
|
+
]
|
143
|
+
# = MANIFEST =
|
144
|
+
|
145
|
+
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
146
|
+
end
|
data/lib/guard/jekyll.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'guard/guard'
|
2
|
+
require 'jekyll/live_site'
|
3
|
+
|
4
|
+
class Guard::Jekyll < Guard::Guard
|
5
|
+
attr_reader :workdir
|
6
|
+
|
7
|
+
def initialize(watchers = [], options = {})
|
8
|
+
super
|
9
|
+
@site = nil
|
10
|
+
@workdir = Dir.pwd
|
11
|
+
end
|
12
|
+
|
13
|
+
def init_site
|
14
|
+
jekyll_options = ::Jekyll::configuration(@options)
|
15
|
+
@site = ::Jekyll::LiveSite.new(jekyll_options)
|
16
|
+
@destination = File.join(File.expand_path(jekyll_options['destination'], @workdir), '')
|
17
|
+
print "Rebuilding Jekyll site... "
|
18
|
+
@site.process
|
19
|
+
puts "done."
|
20
|
+
end
|
21
|
+
alias_method :start, :init_site
|
22
|
+
alias_method :reload, :init_site
|
23
|
+
alias_method :run_all, :init_site
|
24
|
+
|
25
|
+
def run_on_change paths
|
26
|
+
init_site if paths.include? '_config.yml'
|
27
|
+
return if @site.nil?
|
28
|
+
render_files paths
|
29
|
+
end
|
30
|
+
|
31
|
+
def filter_files paths
|
32
|
+
paths.reject { |path| in_destination? path }
|
33
|
+
end
|
34
|
+
|
35
|
+
def in_destination? path
|
36
|
+
File.expand_path(path, workdir).index(@destination) == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
def render_files paths
|
40
|
+
changed = []
|
41
|
+
@site.process_files filter_files(paths) do |processed|
|
42
|
+
relative = processed.sub("#{workdir}/", '')
|
43
|
+
puts "Jekyll: #{relative}"
|
44
|
+
changed << relative
|
45
|
+
end
|
46
|
+
|
47
|
+
notify changed if changed.any?
|
48
|
+
end
|
49
|
+
|
50
|
+
def notify changed_files
|
51
|
+
::Guard.guards.each do |guard|
|
52
|
+
next if self.class === guard
|
53
|
+
paths = ::Guard::Watcher.match_files(guard, changed_files)
|
54
|
+
guard.run_on_change(paths) unless paths.empty?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
class Converter < Plugin
|
4
|
+
# Public: Get or set the pygments prefix. When an argument is specified,
|
5
|
+
# the prefix will be set. If no argument is specified, the current prefix
|
6
|
+
# will be returned.
|
7
|
+
#
|
8
|
+
# pygments_prefix - The String prefix (default: nil).
|
9
|
+
#
|
10
|
+
# Returns the String prefix.
|
11
|
+
def self.pygments_prefix(pygments_prefix = nil)
|
12
|
+
@pygments_prefix = pygments_prefix if pygments_prefix
|
13
|
+
@pygments_prefix
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public: Get or set the pygments suffix. When an argument is specified,
|
17
|
+
# the suffix will be set. If no argument is specified, the current suffix
|
18
|
+
# will be returned.
|
19
|
+
#
|
20
|
+
# pygments_suffix - The String suffix (default: nil).
|
21
|
+
#
|
22
|
+
# Returns the String suffix.
|
23
|
+
def self.pygments_suffix(pygments_suffix = nil)
|
24
|
+
@pygments_suffix = pygments_suffix if pygments_suffix
|
25
|
+
@pygments_suffix
|
26
|
+
end
|
27
|
+
|
28
|
+
# Initialize the converter.
|
29
|
+
#
|
30
|
+
# Returns an initialized Converter.
|
31
|
+
def initialize(config = {})
|
32
|
+
@config = config
|
33
|
+
end
|
34
|
+
|
35
|
+
# Get the pygments prefix.
|
36
|
+
#
|
37
|
+
# Returns the String prefix.
|
38
|
+
def pygments_prefix
|
39
|
+
self.class.pygments_prefix
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get the pygments suffix.
|
43
|
+
#
|
44
|
+
# Returns the String suffix.
|
45
|
+
def pygments_suffix
|
46
|
+
self.class.pygments_suffix
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
class MarkdownConverter < Converter
|
4
|
+
safe true
|
5
|
+
|
6
|
+
pygments_prefix "\n"
|
7
|
+
pygments_suffix "\n"
|
8
|
+
|
9
|
+
def setup
|
10
|
+
return if @setup
|
11
|
+
# Set the Markdown interpreter (and Maruku self.config, if necessary)
|
12
|
+
case @config['markdown']
|
13
|
+
when 'redcarpet'
|
14
|
+
begin
|
15
|
+
require 'redcarpet'
|
16
|
+
@redcarpet_extensions = @config['redcarpet']['extensions'].map { |e| e.to_sym }
|
17
|
+
rescue LoadError
|
18
|
+
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
19
|
+
STDERR.puts ' $ [sudo] gem install redcarpet'
|
20
|
+
raise FatalException.new("Missing dependency: redcarpet")
|
21
|
+
end
|
22
|
+
when 'kramdown'
|
23
|
+
begin
|
24
|
+
require 'kramdown'
|
25
|
+
rescue LoadError
|
26
|
+
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
27
|
+
STDERR.puts ' $ [sudo] gem install kramdown'
|
28
|
+
raise FatalException.new("Missing dependency: kramdown")
|
29
|
+
end
|
30
|
+
when 'rdiscount'
|
31
|
+
begin
|
32
|
+
require 'rdiscount'
|
33
|
+
|
34
|
+
# Load rdiscount extensions
|
35
|
+
@rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
|
36
|
+
rescue LoadError
|
37
|
+
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
38
|
+
STDERR.puts ' $ [sudo] gem install rdiscount'
|
39
|
+
raise FatalException.new("Missing dependency: rdiscount")
|
40
|
+
end
|
41
|
+
when 'maruku'
|
42
|
+
begin
|
43
|
+
require 'maruku'
|
44
|
+
|
45
|
+
if @config['maruku']['use_divs']
|
46
|
+
require 'maruku/ext/div'
|
47
|
+
STDERR.puts 'Maruku: Using extended syntax for div elements.'
|
48
|
+
end
|
49
|
+
|
50
|
+
if @config['maruku']['use_tex']
|
51
|
+
require 'maruku/ext/math'
|
52
|
+
STDERR.puts "Maruku: Using LaTeX extension. Images in `#{@config['maruku']['png_dir']}`."
|
53
|
+
|
54
|
+
# Switch off MathML output
|
55
|
+
MaRuKu::Globals[:html_math_output_mathml] = false
|
56
|
+
MaRuKu::Globals[:html_math_engine] = 'none'
|
57
|
+
|
58
|
+
# Turn on math to PNG support with blahtex
|
59
|
+
# Resulting PNGs stored in `images/latex`
|
60
|
+
MaRuKu::Globals[:html_math_output_png] = true
|
61
|
+
MaRuKu::Globals[:html_png_engine] = @config['maruku']['png_engine']
|
62
|
+
MaRuKu::Globals[:html_png_dir] = @config['maruku']['png_dir']
|
63
|
+
MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url']
|
64
|
+
end
|
65
|
+
rescue LoadError
|
66
|
+
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
67
|
+
STDERR.puts ' $ [sudo] gem install maruku'
|
68
|
+
raise FatalException.new("Missing dependency: maruku")
|
69
|
+
end
|
70
|
+
else
|
71
|
+
STDERR.puts "Invalid Markdown processor: #{@config['markdown']}"
|
72
|
+
STDERR.puts " Valid options are [ maruku | rdiscount | kramdown ]"
|
73
|
+
raise FatalException.new("Invalid Markdown process: #{@config['markdown']}")
|
74
|
+
end
|
75
|
+
@setup = true
|
76
|
+
end
|
77
|
+
|
78
|
+
def matches(ext)
|
79
|
+
rgx = '(' + @config['markdown_ext'].gsub(',','|') +')'
|
80
|
+
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
81
|
+
end
|
82
|
+
|
83
|
+
def output_ext(ext)
|
84
|
+
".html"
|
85
|
+
end
|
86
|
+
|
87
|
+
def convert(content)
|
88
|
+
setup
|
89
|
+
case @config['markdown']
|
90
|
+
when 'redcarpet'
|
91
|
+
Redcarpet.new(content, *@redcarpet_extensions).to_html
|
92
|
+
when 'kramdown'
|
93
|
+
# Check for use of coderay
|
94
|
+
if @config['kramdown']['use_coderay']
|
95
|
+
Kramdown::Document.new(content, {
|
96
|
+
:auto_ids => @config['kramdown']['auto_ids'],
|
97
|
+
:footnote_nr => @config['kramdown']['footnote_nr'],
|
98
|
+
:entity_output => @config['kramdown']['entity_output'],
|
99
|
+
:toc_levels => @config['kramdown']['toc_levels'],
|
100
|
+
|
101
|
+
:coderay_wrap => @config['kramdown']['coderay']['coderay_wrap'],
|
102
|
+
:coderay_line_numbers => @config['kramdown']['coderay']['coderay_line_numbers'],
|
103
|
+
:coderay_line_number_start => @config['kramdown']['coderay']['coderay_line_number_start'],
|
104
|
+
:coderay_tab_width => @config['kramdown']['coderay']['coderay_tab_width'],
|
105
|
+
:coderay_bold_every => @config['kramdown']['coderay']['coderay_bold_every'],
|
106
|
+
:coderay_css => @config['kramdown']['coderay']['coderay_css']
|
107
|
+
}).to_html
|
108
|
+
else
|
109
|
+
# not using coderay
|
110
|
+
Kramdown::Document.new(content, {
|
111
|
+
:auto_ids => @config['kramdown']['auto_ids'],
|
112
|
+
:footnote_nr => @config['kramdown']['footnote_nr'],
|
113
|
+
:entity_output => @config['kramdown']['entity_output'],
|
114
|
+
:toc_levels => @config['kramdown']['toc_levels']
|
115
|
+
}).to_html
|
116
|
+
end
|
117
|
+
when 'rdiscount'
|
118
|
+
RDiscount.new(content, *@rdiscount_extensions).to_html
|
119
|
+
when 'maruku'
|
120
|
+
Maruku.new(content).to_html
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
class TextileConverter < Converter
|
4
|
+
safe true
|
5
|
+
|
6
|
+
pygments_prefix '<notextile>'
|
7
|
+
pygments_suffix '</notextile>'
|
8
|
+
|
9
|
+
def setup
|
10
|
+
return if @setup
|
11
|
+
require 'redcloth'
|
12
|
+
@setup = true
|
13
|
+
rescue LoadError
|
14
|
+
STDERR.puts 'You are missing a library required for Textile. Please run:'
|
15
|
+
STDERR.puts ' $ [sudo] gem install RedCloth'
|
16
|
+
raise FatalException.new("Missing dependency: RedCloth")
|
17
|
+
end
|
18
|
+
|
19
|
+
def matches(ext)
|
20
|
+
rgx = '(' + @config['textile_ext'].gsub(',','|') +')'
|
21
|
+
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
22
|
+
end
|
23
|
+
|
24
|
+
def output_ext(ext)
|
25
|
+
".html"
|
26
|
+
end
|
27
|
+
|
28
|
+
def convert(content)
|
29
|
+
setup
|
30
|
+
|
31
|
+
# Shortcut if config doesn't contain RedCloth section
|
32
|
+
return RedCloth.new(content).to_html if @config['redcloth'].nil?
|
33
|
+
|
34
|
+
# List of attributes defined on RedCloth
|
35
|
+
# (from http://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html)
|
36
|
+
attrs = ['filter_classes', 'filter_html', 'filter_ids', 'filter_styles',
|
37
|
+
'hard_breaks', 'lite_mode', 'no_span_caps', 'sanitize_html']
|
38
|
+
|
39
|
+
r = RedCloth.new(content)
|
40
|
+
|
41
|
+
# Set attributes in r if they are NOT nil in the config
|
42
|
+
attrs.each do |attr|
|
43
|
+
r.instance_variable_set("@#{attr}".to_sym, @config['redcloth'][attr]) unless @config['redcloth'][attr].nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
r.to_html
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
# Convertible provides methods for converting a pagelike item
|
4
|
+
# from a certain type of markup into actual content
|
5
|
+
#
|
6
|
+
# Requires
|
7
|
+
# self.site -> Jekyll::Site
|
8
|
+
# self.content
|
9
|
+
# self.content=
|
10
|
+
# self.data
|
11
|
+
# self.data=
|
12
|
+
# self.ext
|
13
|
+
# self.output
|
14
|
+
# self.output=
|
15
|
+
# self.name
|
16
|
+
module Jekyll
|
17
|
+
module Convertible
|
18
|
+
# Returns the contents as a String.
|
19
|
+
def to_s
|
20
|
+
self.content || ''
|
21
|
+
end
|
22
|
+
|
23
|
+
# Read the YAML frontmatter.
|
24
|
+
#
|
25
|
+
# base - The String path to the dir containing the file.
|
26
|
+
# name - The String filename of the file.
|
27
|
+
#
|
28
|
+
# Returns nothing.
|
29
|
+
def read_yaml(base, name)
|
30
|
+
self.content = File.read(File.join(base, name))
|
31
|
+
|
32
|
+
if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
33
|
+
self.content = $POSTMATCH
|
34
|
+
data = begin
|
35
|
+
YAML.load($1)
|
36
|
+
rescue => e
|
37
|
+
puts "YAML Exception reading #{name}: #{e.message}"
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
self.data = data
|
41
|
+
end
|
42
|
+
|
43
|
+
self.data ||= {}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Transform the contents based on the content type.
|
47
|
+
#
|
48
|
+
# Returns nothing.
|
49
|
+
def transform
|
50
|
+
self.content = converter.convert(self.content)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Determine the extension depending on content_type.
|
54
|
+
#
|
55
|
+
# Returns the String extension for the output file.
|
56
|
+
# e.g. ".html" for an HTML output file.
|
57
|
+
def output_ext
|
58
|
+
converter.output_ext(self.ext)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Determine which converter to use based on this convertible's
|
62
|
+
# extension.
|
63
|
+
#
|
64
|
+
# Returns the Converter instance.
|
65
|
+
def converter
|
66
|
+
@converter ||= self.site.converters.find { |c| c.matches(self.ext) }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Add any necessary layouts to this convertible document.
|
70
|
+
#
|
71
|
+
# payload - The site payload Hash.
|
72
|
+
# layouts - A Hash of {"name" => "layout"}.
|
73
|
+
#
|
74
|
+
# Returns nothing.
|
75
|
+
def do_layout(payload, layouts)
|
76
|
+
info = { :filters => [Jekyll::Filters], :registers => { :site => self.site } }
|
77
|
+
|
78
|
+
# render and transform content (this becomes the final content of the object)
|
79
|
+
payload["pygments_prefix"] = converter.pygments_prefix
|
80
|
+
payload["pygments_suffix"] = converter.pygments_suffix
|
81
|
+
|
82
|
+
begin
|
83
|
+
self.content = Liquid::Template.parse(self.content).render(payload, info)
|
84
|
+
rescue => e
|
85
|
+
puts "Liquid Exception: #{e.message} in #{self.name}"
|
86
|
+
end
|
87
|
+
|
88
|
+
self.transform
|
89
|
+
|
90
|
+
# output keeps track of what will finally be written
|
91
|
+
self.output = self.content
|
92
|
+
|
93
|
+
# recursively render layouts
|
94
|
+
layout = layouts[self.data["layout"]]
|
95
|
+
used = Set.new([layout])
|
96
|
+
|
97
|
+
while layout
|
98
|
+
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
99
|
+
|
100
|
+
begin
|
101
|
+
self.output = Liquid::Template.parse(layout.content).render(payload, info)
|
102
|
+
rescue => e
|
103
|
+
puts "Liquid Exception: #{e.message} in #{self.data["layout"]}"
|
104
|
+
end
|
105
|
+
|
106
|
+
if layout = layouts[layout.data["layout"]]
|
107
|
+
if used.include?(layout)
|
108
|
+
layout = nil # avoid recursive chain
|
109
|
+
else
|
110
|
+
used << layout
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class Hash
|
2
|
+
# Merges self with another hash, recursively.
|
3
|
+
#
|
4
|
+
# This code was lovingly stolen from some random gem:
|
5
|
+
# http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
|
6
|
+
#
|
7
|
+
# Thanks to whoever made it.
|
8
|
+
def deep_merge(hash)
|
9
|
+
target = dup
|
10
|
+
|
11
|
+
hash.keys.each do |key|
|
12
|
+
if hash[key].is_a? Hash and self[key].is_a? Hash
|
13
|
+
target[key] = target[key].deep_merge(hash[key])
|
14
|
+
next
|
15
|
+
end
|
16
|
+
|
17
|
+
target[key] = hash[key]
|
18
|
+
end
|
19
|
+
|
20
|
+
target
|
21
|
+
end
|
22
|
+
|
23
|
+
# Read array from the supplied hash favouring the singular key
|
24
|
+
# and then the plural key, and handling any nil entries.
|
25
|
+
# +hash+ the hash to read from
|
26
|
+
# +singular_key+ the singular key
|
27
|
+
# +plural_key+ the singular key
|
28
|
+
#
|
29
|
+
# Returns an array
|
30
|
+
def pluralized_array(singular_key, plural_key)
|
31
|
+
hash = self
|
32
|
+
if hash.has_key?(singular_key)
|
33
|
+
array = [hash[singular_key]] if hash[singular_key]
|
34
|
+
elsif hash.has_key?(plural_key)
|
35
|
+
case hash[plural_key]
|
36
|
+
when String
|
37
|
+
array = hash[plural_key].split
|
38
|
+
when Array
|
39
|
+
array = hash[plural_key].compact
|
40
|
+
end
|
41
|
+
end
|
42
|
+
array || []
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Thanks, ActiveSupport!
|
47
|
+
class Date
|
48
|
+
# Converts datetime to an appropriate format for use in XML
|
49
|
+
def xmlschema
|
50
|
+
strftime("%Y-%m-%dT%H:%M:%S%Z")
|
51
|
+
end if RUBY_VERSION < '1.9'
|
52
|
+
end
|