spinto-jekyll 0.11.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/History.txt +321 -0
- data/LICENSE +21 -0
- data/README.textile +41 -0
- data/Rakefile +166 -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/lib/jekyll.rb +136 -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 +112 -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 +44 -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 +155 -0
- data/lib/jekyll/plugin.rb +77 -0
- data/lib/jekyll/post.rb +257 -0
- data/lib/jekyll/site.rb +337 -0
- data/lib/jekyll/static_file.rb +72 -0
- data/lib/jekyll/tags/highlight.rb +76 -0
- data/lib/jekyll/tags/include.rb +37 -0
- data/lib/jekyll/tags/post_url.rb +38 -0
- data/lib/spinto-jekyll.rb +3 -0
- data/spinto-jekyll.gemspec +155 -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 +456 -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 +336 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Before do
|
|
2
|
+
FileUtils.mkdir(TEST_DIR)
|
|
3
|
+
Dir.chdir(TEST_DIR)
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
After do
|
|
7
|
+
Dir.chdir(TEST_DIR)
|
|
8
|
+
FileUtils.rm_rf(TEST_DIR)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Given /^I have a blank site in "(.*)"$/ do |path|
|
|
12
|
+
FileUtils.mkdir(path)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
|
|
16
|
+
Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
|
|
17
|
+
File.open(file, 'w') do |f|
|
|
18
|
+
f.write <<EOF
|
|
19
|
+
---
|
|
20
|
+
#{key || 'layout'}: #{value || 'nil'}
|
|
21
|
+
---
|
|
22
|
+
#{text}
|
|
23
|
+
EOF
|
|
24
|
+
f.close
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Given /^I have an? "(.*)" file that contains "(.*)"$/ do |file, text|
|
|
29
|
+
File.open(file, 'w') do |f|
|
|
30
|
+
f.write(text)
|
|
31
|
+
f.close
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text|
|
|
36
|
+
File.open(File.join('_layouts', layout + '.html'), 'w') do |f|
|
|
37
|
+
f.write(text)
|
|
38
|
+
f.close
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
Given /^I have an? (.*) directory$/ do |dir|
|
|
43
|
+
FileUtils.mkdir_p(dir)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
Given /^I have the following posts?(?: (.*) "(.*)")?:$/ do |direction, folder, table|
|
|
47
|
+
table.hashes.each do |post|
|
|
48
|
+
date = Date.strptime(post['date'], '%m/%d/%Y').strftime('%Y-%m-%d')
|
|
49
|
+
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
|
50
|
+
|
|
51
|
+
if direction && direction == "in"
|
|
52
|
+
before = folder || '.'
|
|
53
|
+
elsif direction && direction == "under"
|
|
54
|
+
after = folder || '.'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{post['type'] || 'textile'}")
|
|
58
|
+
|
|
59
|
+
matter_hash = {}
|
|
60
|
+
%w(title layout tag tags category categories published author).each do |key|
|
|
61
|
+
matter_hash[key] = post[key] if post[key]
|
|
62
|
+
end
|
|
63
|
+
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
|
|
64
|
+
|
|
65
|
+
content = post['content']
|
|
66
|
+
if post['input'] && post['filter']
|
|
67
|
+
content = "{{ #{post['input']} | #{post['filter']} }}"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
File.open(path, 'w') do |f|
|
|
71
|
+
f.write <<EOF
|
|
72
|
+
---
|
|
73
|
+
#{matter}
|
|
74
|
+
---
|
|
75
|
+
#{content}
|
|
76
|
+
EOF
|
|
77
|
+
f.close
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value|
|
|
83
|
+
File.open('_config.yml', 'w') do |f|
|
|
84
|
+
f.write("#{key}: #{value}\n")
|
|
85
|
+
f.close
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
Given /^I have a configuration file with:$/ do |table|
|
|
90
|
+
File.open('_config.yml', 'w') do |f|
|
|
91
|
+
table.hashes.each do |row|
|
|
92
|
+
f.write("#{row["key"]}: #{row["value"]}\n")
|
|
93
|
+
end
|
|
94
|
+
f.close
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
|
|
99
|
+
File.open('_config.yml', 'w') do |f|
|
|
100
|
+
f.write("#{key}:\n")
|
|
101
|
+
table.hashes.each do |row|
|
|
102
|
+
f.write("- #{row["value"]}\n")
|
|
103
|
+
end
|
|
104
|
+
f.close
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
When /^I run jekyll$/ do
|
|
110
|
+
run_jekyll
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
When /^I debug jekyll$/ do
|
|
114
|
+
run_jekyll(:debug => true)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
|
118
|
+
File.open(file, 'a') do |f|
|
|
119
|
+
f.write(text)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
Then /^the (.*) directory should exist$/ do |dir|
|
|
124
|
+
assert File.directory?(dir)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
|
128
|
+
assert_match Regexp.new(text), File.open(file).readlines.join
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
Then /^the "(.*)" file should exist$/ do |file|
|
|
132
|
+
assert File.file?(file)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
Then /^the "(.*)" file should not exist$/ do |file|
|
|
136
|
+
assert !File.exists?(file)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
Then /^I should see today's time in "(.*)"$/ do |file|
|
|
140
|
+
assert_match Regexp.new(Regexp.escape(Time.now.to_s)), File.open(file).readlines.join
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
Then /^I should see today's date in "(.*)"$/ do |file|
|
|
144
|
+
assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join
|
|
145
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'rr'
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
|
|
5
|
+
World do
|
|
6
|
+
include Test::Unit::Assertions
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
TEST_DIR = File.join('/', 'tmp', 'jekyll')
|
|
10
|
+
JEKYLL_PATH = File.join(ENV['PWD'], 'bin', 'jekyll')
|
|
11
|
+
|
|
12
|
+
def run_jekyll(opts = {})
|
|
13
|
+
command = JEKYLL_PATH
|
|
14
|
+
command << " >> /dev/null 2>&1" if opts[:debug].nil?
|
|
15
|
+
system command
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# work around "invalid option: --format" cucumber bug (see #296)
|
|
19
|
+
Test::Unit.run = true if RUBY_VERSION < '1.9'
|
data/lib/jekyll.rb
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
|
2
|
+
|
|
3
|
+
# Require all of the Ruby files in the given directory.
|
|
4
|
+
#
|
|
5
|
+
# path - The String relative path from here to the directory.
|
|
6
|
+
#
|
|
7
|
+
# Returns nothing.
|
|
8
|
+
def require_all(path)
|
|
9
|
+
glob = File.join(File.dirname(__FILE__), path, '*.rb')
|
|
10
|
+
Dir[glob].each do |f|
|
|
11
|
+
require f
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# rubygems
|
|
16
|
+
require 'rubygems'
|
|
17
|
+
|
|
18
|
+
# stdlib
|
|
19
|
+
require 'fileutils'
|
|
20
|
+
require 'time'
|
|
21
|
+
require 'yaml'
|
|
22
|
+
require 'English'
|
|
23
|
+
|
|
24
|
+
# 3rd party
|
|
25
|
+
require 'liquid'
|
|
26
|
+
require 'maruku'
|
|
27
|
+
require 'albino'
|
|
28
|
+
|
|
29
|
+
# internal requires
|
|
30
|
+
require 'jekyll/core_ext'
|
|
31
|
+
require 'jekyll/site'
|
|
32
|
+
require 'jekyll/convertible'
|
|
33
|
+
require 'jekyll/layout'
|
|
34
|
+
require 'jekyll/page'
|
|
35
|
+
require 'jekyll/post'
|
|
36
|
+
require 'jekyll/filters'
|
|
37
|
+
require 'jekyll/static_file'
|
|
38
|
+
require 'jekyll/errors'
|
|
39
|
+
|
|
40
|
+
# extensions
|
|
41
|
+
require 'jekyll/plugin'
|
|
42
|
+
require 'jekyll/converter'
|
|
43
|
+
require 'jekyll/generator'
|
|
44
|
+
require_all 'jekyll/converters'
|
|
45
|
+
require_all 'jekyll/generators'
|
|
46
|
+
require_all 'jekyll/tags'
|
|
47
|
+
|
|
48
|
+
module Jekyll
|
|
49
|
+
VERSION = '0.11.2'
|
|
50
|
+
|
|
51
|
+
# Default options. Overriden by values in _config.yml or command-line opts.
|
|
52
|
+
# (Strings rather symbols used for compatability with YAML).
|
|
53
|
+
DEFAULTS = {
|
|
54
|
+
'safe' => false,
|
|
55
|
+
'auto' => false,
|
|
56
|
+
'server' => false,
|
|
57
|
+
'server_port' => 4000,
|
|
58
|
+
|
|
59
|
+
'source' => Dir.pwd,
|
|
60
|
+
'destination' => File.join(Dir.pwd, '_site'),
|
|
61
|
+
'plugins' => File.join(Dir.pwd, '_plugins'),
|
|
62
|
+
|
|
63
|
+
'future' => true,
|
|
64
|
+
'lsi' => false,
|
|
65
|
+
'pygments' => false,
|
|
66
|
+
'markdown' => 'maruku',
|
|
67
|
+
'permalink' => 'date',
|
|
68
|
+
'include' => ['.htaccess'],
|
|
69
|
+
|
|
70
|
+
'markdown_ext' => 'markdown,mkd,mkdn,md',
|
|
71
|
+
'textile_ext' => 'textile',
|
|
72
|
+
|
|
73
|
+
'maruku' => {
|
|
74
|
+
'use_tex' => false,
|
|
75
|
+
'use_divs' => false,
|
|
76
|
+
'png_engine' => 'blahtex',
|
|
77
|
+
'png_dir' => 'images/latex',
|
|
78
|
+
'png_url' => '/images/latex'
|
|
79
|
+
},
|
|
80
|
+
'rdiscount' => {
|
|
81
|
+
'extensions' => []
|
|
82
|
+
},
|
|
83
|
+
'redcarpet' => {
|
|
84
|
+
'extensions' => []
|
|
85
|
+
},
|
|
86
|
+
'kramdown' => {
|
|
87
|
+
'auto_ids' => true,
|
|
88
|
+
'footnote_nr' => 1,
|
|
89
|
+
'entity_output' => 'as_char',
|
|
90
|
+
'toc_levels' => '1..6',
|
|
91
|
+
'use_coderay' => false,
|
|
92
|
+
|
|
93
|
+
'coderay' => {
|
|
94
|
+
'coderay_wrap' => 'div',
|
|
95
|
+
'coderay_line_numbers' => 'inline',
|
|
96
|
+
'coderay_line_number_start' => 1,
|
|
97
|
+
'coderay_tab_width' => 4,
|
|
98
|
+
'coderay_bold_every' => 10,
|
|
99
|
+
'coderay_css' => 'style'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
'redcloth' => {
|
|
103
|
+
'hard_breaks' => true
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# Public: Generate a Jekyll configuration Hash by merging the default
|
|
108
|
+
# options with anything in _config.yml, and adding the given options on top.
|
|
109
|
+
#
|
|
110
|
+
# override - A Hash of config directives that override any options in both
|
|
111
|
+
# the defaults and the config file. See Jekyll::DEFAULTS for a
|
|
112
|
+
# list of option names and their defaults.
|
|
113
|
+
#
|
|
114
|
+
# Returns the final configuration Hash.
|
|
115
|
+
def self.configuration(override)
|
|
116
|
+
# _config.yml may override default source location, but until
|
|
117
|
+
# then, we need to know where to look for _config.yml
|
|
118
|
+
source = override['source'] || Jekyll::DEFAULTS['source']
|
|
119
|
+
|
|
120
|
+
# Get configuration from <source>/_config.yml
|
|
121
|
+
config_file = File.join(source, '_config.yml')
|
|
122
|
+
begin
|
|
123
|
+
config = YAML.load_file(config_file)
|
|
124
|
+
raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash)
|
|
125
|
+
$stdout.puts "Configuration from #{config_file}"
|
|
126
|
+
rescue => err
|
|
127
|
+
$stderr.puts "WARNING: Could not read configuration. " +
|
|
128
|
+
"Using defaults (and options)."
|
|
129
|
+
$stderr.puts "\t" + err.to_s
|
|
130
|
+
config = {}
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Merge DEFAULTS < _config.yml < override
|
|
134
|
+
Jekyll::DEFAULTS.deep_merge(config).deep_merge(override)
|
|
135
|
+
end
|
|
136
|
+
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
|