mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
Compare commits
130 Commits
v2.5.3
...
cache-incl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c5399b947 | ||
|
|
0d6064b1a1 | ||
|
|
32ff033f9f | ||
|
|
d47b882af2 | ||
|
|
2f4e5fa28b | ||
|
|
c4d617e6aa | ||
|
|
f95d0ba840 | ||
|
|
502fd94f2c | ||
|
|
c58ac78a5e | ||
|
|
7655b533c9 | ||
|
|
620115a986 | ||
|
|
1ca06e70d3 | ||
|
|
919d37fb37 | ||
|
|
f7dafb1f04 | ||
|
|
6504645c60 | ||
|
|
fc0ea20a85 | ||
|
|
b20a175c27 | ||
|
|
2f06f4aad7 | ||
|
|
ff3fa84b8a | ||
|
|
7f370cb82f | ||
|
|
51951c43e8 | ||
|
|
a88f2567f7 | ||
|
|
d159684f87 | ||
|
|
d29dd11ae3 | ||
|
|
8d968ebae0 | ||
|
|
86f7196ef5 | ||
|
|
064d6de48d | ||
|
|
21bd3e6c5a | ||
|
|
07bd3a3759 | ||
|
|
e40e12fabd | ||
|
|
a098dc80cd | ||
|
|
419aaba07c | ||
|
|
7cd5847826 | ||
|
|
9109da32f9 | ||
|
|
7bcf8d689e | ||
|
|
f66862c508 | ||
|
|
cb95a72f5a | ||
|
|
9b81f29625 | ||
|
|
5e10958faa | ||
|
|
7f034f51e3 | ||
|
|
1fc99bdd97 | ||
|
|
7fc47bfc43 | ||
|
|
b2146e8659 | ||
|
|
e0a011c917 | ||
|
|
63ec07a062 | ||
|
|
5f03314d85 | ||
|
|
442deb6a7e | ||
|
|
d7d7d924f7 | ||
|
|
35a5af783a | ||
|
|
a6781bda30 | ||
|
|
bab7ef4b1d | ||
|
|
6f7ea381b3 | ||
|
|
612eb737a5 | ||
|
|
191c2279d2 | ||
|
|
e39dfa3f0b | ||
|
|
5af7694f3b | ||
|
|
6e5850c6ab | ||
|
|
be23e18555 | ||
|
|
928be16fab | ||
|
|
eac3ac095f | ||
|
|
aa4beda868 | ||
|
|
1fad3a074f | ||
|
|
0fe2094dd2 | ||
|
|
c576d23908 | ||
|
|
8c19a6f430 | ||
|
|
ac41312c5d | ||
|
|
232a58d5b4 | ||
|
|
0c0aea3ad7 | ||
|
|
657b16519e | ||
|
|
f81601ee53 | ||
|
|
b6641be8ef | ||
|
|
a8ec9cd507 | ||
|
|
2f8248a6f1 | ||
|
|
0eb2796a66 | ||
|
|
e120c255ff | ||
|
|
990a9e6e6d | ||
|
|
c24c6b7f3d | ||
|
|
039c521e8c | ||
|
|
d35af9c1f3 | ||
|
|
f6bff6fb61 | ||
|
|
a103898980 | ||
|
|
3957efac15 | ||
|
|
38309569c4 | ||
|
|
8bfc696569 | ||
|
|
b68dd3a5cb | ||
|
|
3940e1e9df | ||
|
|
70a331d854 | ||
|
|
5bf1596414 | ||
|
|
3234041510 | ||
|
|
37631eefac | ||
|
|
82b1ad0552 | ||
|
|
2c2347fac1 | ||
|
|
0aa61f66a8 | ||
|
|
b1a517ccb6 | ||
|
|
4070143d5b | ||
|
|
6e4e290ab0 | ||
|
|
d6995d347a | ||
|
|
52085d2e34 | ||
|
|
f3a274377a | ||
|
|
0fcba080c3 | ||
|
|
922ba5d0ea | ||
|
|
cb2eea0e41 | ||
|
|
aaf6f28fde | ||
|
|
7227ad4ebb | ||
|
|
59acdaab9a | ||
|
|
43a28aed96 | ||
|
|
5d9662f80f | ||
|
|
ed9cc80ff9 | ||
|
|
9b6eeba81e | ||
|
|
40e4c031e3 | ||
|
|
f80dc07f82 | ||
|
|
52f0b36558 | ||
|
|
d0e12d69bc | ||
|
|
a701e59c07 | ||
|
|
b6d81c58df | ||
|
|
02f281eef3 | ||
|
|
8a257aca6b | ||
|
|
dc30114605 | ||
|
|
2a5cf11ee2 | ||
|
|
75c5c16297 | ||
|
|
4acf343fea | ||
|
|
ac03af3229 | ||
|
|
fe6bfc6f1b | ||
|
|
d438362971 | ||
|
|
842470b0c4 | ||
|
|
11917645f2 | ||
|
|
f9e249ae20 | ||
|
|
c3ec158f2d | ||
|
|
6c0e791236 | ||
|
|
1aa9d6255e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@ coverage
|
||||
.ruby-version
|
||||
.sass-cache
|
||||
tmp/stackprof-*
|
||||
.jekyll-metadata
|
||||
|
||||
@@ -2,9 +2,9 @@ language: ruby
|
||||
cache: bundler
|
||||
sudo: false
|
||||
rvm:
|
||||
- 2.2
|
||||
- 2.1
|
||||
- 2.0
|
||||
- 1.9.3
|
||||
env:
|
||||
matrix:
|
||||
- TEST_SUITE=test
|
||||
|
||||
22
Gemfile
22
Gemfile
@@ -1,7 +1,29 @@
|
||||
source 'https://rubygems.org'
|
||||
gemspec
|
||||
|
||||
gem 'rake', '~> 10.1'
|
||||
gem 'rdoc', '~> 3.11'
|
||||
gem 'redgreen', '~> 1.2'
|
||||
gem 'shoulda', '~> 3.5'
|
||||
gem 'rr', '~> 1.1'
|
||||
gem 'cucumber', '1.3.18'
|
||||
gem 'RedCloth', '~> 4.2'
|
||||
gem 'maruku', '~> 0.7.0'
|
||||
gem 'rdiscount', '~> 1.6'
|
||||
gem 'launchy', '~> 2.3'
|
||||
gem 'simplecov', '~> 0.9'
|
||||
gem 'simplecov-gem-adapter', '~> 1.0.1'
|
||||
gem 'mime-types', '~> 1.5'
|
||||
gem 'activesupport', '~> 3.2.13'
|
||||
gem 'jekyll_test_plugin'
|
||||
gem 'jekyll_test_plugin_malicious'
|
||||
gem 'rouge', '~> 1.7'
|
||||
gem 'liquid-c', '~> 0.0.3'
|
||||
gem 'minitest' if RUBY_PLATFORM =~ /cygwin/
|
||||
gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2")
|
||||
|
||||
if ENV['BENCHMARK']
|
||||
gem 'benchmark-ips'
|
||||
gem 'rbtrace'
|
||||
gem 'stackprof'
|
||||
end
|
||||
|
||||
@@ -2,14 +2,45 @@
|
||||
|
||||
### Major Enhancements
|
||||
|
||||
* Incremental regeneration (#3116)
|
||||
* Drop support for Ruby 1.9.3. (#3235)
|
||||
* Upgrade to Liquid 3.0.0 (#3002)
|
||||
* Support Ruby v2.2 (#3234)
|
||||
|
||||
### Minor Enhancements
|
||||
|
||||
* Sort static files just once, and call `site_payload` once for all collections (#3204)
|
||||
* Separate `jekyll docs` and optimize external gem handling (#3241)
|
||||
* Improve `Site#getConverterImpl` and call it `Site#find_converter_instance` (#3240)
|
||||
* Use relative path for `path` Liquid variable in Documents for consistency (#2908)
|
||||
* Generalize `Utils#slugify` for any scripts (#3047)
|
||||
* Added basic microdata to post template in site template (#3189)
|
||||
* Store log messages in an array of messages. (#3244)
|
||||
* Allow collection documents to override `output` property in front matter (#3172)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Remove unneeded end tag for `link` in site template (#3236)
|
||||
* Kramdown: Use `enable_coderay` key instead of `use_coderay` (#3237)
|
||||
* Unescape `Document` output path (#2924)
|
||||
* Fix nav items alignment when on multiple rows (#3264)
|
||||
|
||||
### Development Fixes
|
||||
|
||||
* Improve the grammar in the documentation (#3233)
|
||||
* Update the LICENSE text to match the MIT license exactly (#3253)
|
||||
* Update rake task `site:publish` to fix minor bugs. (#3254)
|
||||
* Switch to shields.io for the README badges. (#3255)
|
||||
* Use `FileList` instead of `Dir.glob` in `site:publish` rake task (#3261)
|
||||
|
||||
### Site Enhancements
|
||||
|
||||
* Fixing the default host on docs (#3229)
|
||||
* Add `jekyll-thumbnail-filter` to list of third-party plugins (#2790)
|
||||
* Add link to 'Adding Ajax pagination to Jekyll' to Resources page (#3186)
|
||||
* Add a Resources link to tutorial on building dynamic navbars (#3185)
|
||||
* Semantic structure improvements to the post and page layouts (#3251)
|
||||
|
||||
## 2.5.3 / 2014-12-22
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
6
LICENSE
6
LICENSE
@@ -1,9 +1,9 @@
|
||||
(The MIT License)
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2008-2014 Tom Preston-Werner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the 'Software'), to deal
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
@@ -12,7 +12,7 @@ furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# [Jekyll](http://jekyllrb.com/)
|
||||
|
||||
[](https://rubygems.org/gems/jekyll)
|
||||
[](https://travis-ci.org/jekyll/jekyll)
|
||||
[](https://codeclimate.com/github/jekyll/jekyll)
|
||||
[](https://gemnasium.com/jekyll/jekyll)
|
||||
[](https://rubygems.org/gems/jekyll)
|
||||
[](https://travis-ci.org/jekyll/jekyll)
|
||||
[](https://codeclimate.com/github/jekyll/jekyll)
|
||||
[](https://gemnasium.com/jekyll/jekyll)
|
||||
[](https://hakiri.io/github/jekyll/jekyll/master)
|
||||
|
||||
By Tom Preston-Werner, Nick Quaranto, Parker Moore, and many [awesome contributors](https://github.com/jekyll/jekyll/graphs/contributors)!
|
||||
|
||||
32
Rakefile
32
Rakefile
@@ -179,22 +179,36 @@ namespace :site do
|
||||
# Ensure the gh-pages dir exists so we can generate into it.
|
||||
puts "Checking for gh-pages dir..."
|
||||
unless File.exist?("./gh-pages")
|
||||
puts "No gh-pages directory found. Run the following commands first:"
|
||||
puts " `git clone git@github.com:jekyll/jekyll gh-pages"
|
||||
puts " `cd gh-pages"
|
||||
puts " `git checkout gh-pages`"
|
||||
exit(1)
|
||||
puts "Creating gh-pages dir..."
|
||||
sh "git clone git@github.com:jekyll/jekyll gh-pages"
|
||||
end
|
||||
|
||||
# Ensure gh-pages branch is up to date.
|
||||
# Ensure latest gh-pages branch history.
|
||||
Dir.chdir('gh-pages') do
|
||||
sh "git checkout gh-pages"
|
||||
sh "git pull origin gh-pages"
|
||||
end
|
||||
|
||||
# Copy to gh-pages dir.
|
||||
# Proceed to purge all files in case we removed a file in this release.
|
||||
puts "Cleaning gh-pages directory..."
|
||||
purge_exclude = %w[
|
||||
gh-pages/.
|
||||
gh-pages/..
|
||||
gh-pages/.git
|
||||
]
|
||||
FileList["gh-pages/{*,.*}"].exclude(*purge_exclude).each do |path|
|
||||
sh "rm -rf #{path}"
|
||||
end
|
||||
|
||||
# Copy site to gh-pages dir.
|
||||
puts "Copying site to gh-pages branch..."
|
||||
Dir.glob("site/*") do |path|
|
||||
next if path.include? "_site"
|
||||
copy_exclude = %w[
|
||||
site/.
|
||||
site/..
|
||||
site/.jekyll-metadata
|
||||
site/_site
|
||||
]
|
||||
FileList["site/{*,.*}"].exclude(*copy_exclude).each do |path|
|
||||
sh "cp -R #{path} gh-pages/"
|
||||
end
|
||||
|
||||
|
||||
32
benchmark/cached-includes.rb
Normal file
32
benchmark/cached-includes.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'benchmark/ips'
|
||||
require 'jekyll'
|
||||
|
||||
site = Jekyll::Site.new(Jekyll.configuration({
|
||||
'source' => File.expand_path('../site', __dir__),
|
||||
'destination' => File.expand_path('../site/_site', __dir__)
|
||||
}))
|
||||
payload = Jekyll::Utils.deep_merge_hashes(
|
||||
site.site_payload,
|
||||
{ 'site' => {'page' => site.pages.first.to_liquid } }
|
||||
)
|
||||
info = {
|
||||
filters: [Jekyll::Filters],
|
||||
registers: { :site => site, :page => payload['page'] }
|
||||
}
|
||||
|
||||
class WithoutCacheInclude < Jekyll::Tags::IncludeTag
|
||||
def source(file, context)
|
||||
File.read(file, file_read_opts(context))
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('include_woc', WithoutCacheInclude)
|
||||
|
||||
def parse(tag, payload, info)
|
||||
Liquid::Template.parse("{% #{tag} footer.html %}").render!(payload, info)
|
||||
end
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report('cached') { parse 'include', payload, info }
|
||||
x.report('uncached') { parse 'include_woc', payload, info }
|
||||
end
|
||||
10
bin/jekyll
10
bin/jekyll
@@ -6,12 +6,9 @@ $:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
||||
require 'jekyll'
|
||||
require 'mercenary'
|
||||
|
||||
%w[jekyll-import].each do |blessed_gem|
|
||||
begin
|
||||
require blessed_gem
|
||||
rescue LoadError
|
||||
end
|
||||
end
|
||||
Jekyll::External.require_if_present(
|
||||
Jekyll::External.blessed_gems
|
||||
)
|
||||
|
||||
Jekyll::PluginManager.require_from_bundler
|
||||
|
||||
@@ -32,6 +29,7 @@ Mercenary.program(:jekyll) do |p|
|
||||
|
||||
p.action do |args, options|
|
||||
if args.empty?
|
||||
Jekyll.logger.error "A subcommand is required."
|
||||
puts p
|
||||
else
|
||||
unless p.has_command?(args.first)
|
||||
|
||||
@@ -9,7 +9,7 @@ Feature: Collections
|
||||
And I have a configuration file with "collections" set to "['methods']"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: <p>Use <code>Jekyll.configuration</code> to build a full configuration for use w/Jekyll.</p>\n\n<p>Whatever: foo.bar</p>\n<p><code>Jekyll.sanitized_path</code> is used to make sure your path is in your source.</p>\n<p>Run your generators! default</p>\n<p>Page without title.</p>\n<p>Run your generators! default</p>" in "_site/index.html"
|
||||
And I should see "Collections: <p>Use <code>Jekyll.configuration</code> to build a full configuration for use w/Jekyll.</p>\n\n<p>Whatever: foo.bar</p>\n<p>Signs are nice</p>\n<p><code>Jekyll.sanitized_path</code> is used to make sure your path is in your source.</p>\n<p>Run your generators! default</p>\n<p>Page without title.</p>\n<p>Run your generators! default</p>" in "_site/index.html"
|
||||
And the "_site/methods/configuration.html" file should not exist
|
||||
|
||||
Scenario: Rendered collection
|
||||
@@ -70,7 +70,7 @@ Feature: Collections
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: _methods/configuration.md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
And I should see "Collections: _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
|
||||
Scenario: Collections specified as an hash
|
||||
Given I have an "index.html" page that contains "Collections: {% for method in site.methods %}{{ method.relative_path }} {% endfor %}"
|
||||
@@ -82,7 +82,7 @@ Feature: Collections
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: _methods/configuration.md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
And I should see "Collections: _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
|
||||
Scenario: All the documents
|
||||
Given I have an "index.html" page that contains "All documents: {% for doc in site.documents %}{{ doc.relative_path }} {% endfor %}"
|
||||
@@ -94,7 +94,7 @@ Feature: Collections
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "All documents: _methods/configuration.md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
And I should see "All documents: _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html"
|
||||
|
||||
Scenario: Documents have an output attribute, which is the converted HTML
|
||||
Given I have an "index.html" page that contains "First document's output: {{ site.documents.first.output }}"
|
||||
@@ -130,7 +130,7 @@ Feature: Collections
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "1. of 5: <p>Page without title.</p>" in "_site/index.html"
|
||||
And I should see "1. of 6: <p>Page without title.</p>" in "_site/index.html"
|
||||
|
||||
Scenario: Sort by relative_path
|
||||
Given I have an "index.html" page that contains "Collections: {% assign methods = site.methods | sort: 'relative_path' %}{% for method in methods %}{{ method.title }}, {% endfor %}"
|
||||
@@ -142,4 +142,4 @@ Feature: Collections
|
||||
"""
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Collections: Jekyll.configuration, Jekyll.sanitized_path, Site#generate, , Site#generate," in "_site/index.html"
|
||||
And I should see "Collections: Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, , Site#generate," in "_site/index.html"
|
||||
|
||||
60
features/incremental_rebuild.feature
Normal file
60
features/incremental_rebuild.feature
Normal file
@@ -0,0 +1,60 @@
|
||||
Feature: Incremental rebuild
|
||||
As an impatient hacker who likes to blog
|
||||
I want to be able to make a static site
|
||||
Without waiting too long for it to build
|
||||
|
||||
Scenario: Produce correct output site
|
||||
Given I have a _layouts directory
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| Wargames | 2009-03-27 | default | The only winning move is not to play. |
|
||||
And I have a default layout that contains "Post Layout: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
|
||||
|
||||
Scenario: Generate a metadata file
|
||||
Given I have an "index.html" file that contains "Basic Site"
|
||||
When I run jekyll build
|
||||
Then the ".jekyll-metadata" file should exist
|
||||
|
||||
Scenario: Rebuild when content is changed
|
||||
Given I have an "index.html" file that contains "Basic Site"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Basic Site" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have an "index.html" file that contains "Bacon Site"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Bacon Site" in "_site/index.html"
|
||||
|
||||
Scenario: Rebuild when layout is changed
|
||||
Given I have a _layouts directory
|
||||
And I have an "index.html" page with layout "default" that contains "Basic Site with Layout"
|
||||
And I have a default layout that contains "Page Layout: {{ content }}"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have a default layout that contains "Page Layout Changed: {{ content }}"
|
||||
When I run jekyll build --full-rebuild
|
||||
Then the _site directory should exist
|
||||
And I should see "Page Layout Changed: Basic Site with Layout" in "_site/index.html"
|
||||
|
||||
Scenario: Rebuild when an include is changed
|
||||
Given I have a _includes directory
|
||||
And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
|
||||
And I have an "_includes/about.textile" file that contains "Generated by Jekyll"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
||||
When I wait 1 second
|
||||
Then I have an "_includes/about.textile" file that contains "Regenerated by Jekyll"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/index.html"
|
||||
@@ -47,7 +47,7 @@ Feature: Markdown
|
||||
And I should see "My awesome code" in "_site/index.html"
|
||||
And I should see "<pre><code>My awesome code</code></pre>" in "_site/index.html"
|
||||
|
||||
Scenario: Maruku fenced codeblocks
|
||||
Scenario: Maruku fenced codeblocks with syntax highlighting
|
||||
Given I have a configuration file with "markdown" set to "maruku"
|
||||
And I have an "index.markdown" file with content:
|
||||
"""
|
||||
|
||||
@@ -24,6 +24,7 @@ end
|
||||
After do
|
||||
FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR)
|
||||
FileUtils.rm(JEKYLL_COMMAND_OUTPUT_FILE) if File.exist?(JEKYLL_COMMAND_OUTPUT_FILE)
|
||||
Dir.chdir(File.dirname(TEST_DIR))
|
||||
end
|
||||
|
||||
World(Test::Unit::Assertions)
|
||||
@@ -133,6 +134,10 @@ Given /^I have fixture collections$/ do
|
||||
FileUtils.cp_r File.join(JEKYLL_SOURCE_DIR, "test", "source", "_methods"), source_dir
|
||||
end
|
||||
|
||||
Given /^I wait (\d+) second(s?)$/ do |time, plural|
|
||||
sleep(time.to_f)
|
||||
end
|
||||
|
||||
##################
|
||||
#
|
||||
# Changing stuff
|
||||
@@ -188,7 +193,15 @@ Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file|
|
||||
end
|
||||
|
||||
Then /^the "(.*)" file should +exist$/ do |file|
|
||||
assert File.file?(file), "The file \"#{file}\" does not exist"
|
||||
file_does_exist = File.file?(file)
|
||||
unless file_does_exist
|
||||
all_steps_to_path(file).each do |dir|
|
||||
STDERR.puts ""
|
||||
STDERR.puts "Dir #{dir}:"
|
||||
STDERR.puts Dir["#{dir}/**/*"]
|
||||
end
|
||||
end
|
||||
assert file_does_exist, "The file \"#{file}\" does not exist.\n"
|
||||
end
|
||||
|
||||
Then /^the "(.*)" file should not exist$/ do |file|
|
||||
|
||||
@@ -13,6 +13,17 @@ def source_dir(*files)
|
||||
File.join(TEST_DIR, *files)
|
||||
end
|
||||
|
||||
def all_steps_to_path(path)
|
||||
source = Pathname.new(source_dir('_site')).expand_path
|
||||
dest = Pathname.new(path).expand_path
|
||||
paths = []
|
||||
dest.ascend do |f|
|
||||
break if f.eql? source
|
||||
paths.unshift f.to_s
|
||||
end
|
||||
paths
|
||||
end
|
||||
|
||||
def jekyll_output_file
|
||||
JEKYLL_COMMAND_OUTPUT_FILE
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
||||
s.specification_version = 2 if s.respond_to? :specification_version=
|
||||
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
||||
s.rubygems_version = '2.2.2'
|
||||
s.required_ruby_version = '>= 1.9.3'
|
||||
s.required_ruby_version = '>= 2.0.0'
|
||||
|
||||
s.name = 'jekyll'
|
||||
s.version = Jekyll::VERSION
|
||||
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
||||
s.rdoc_options = ['--charset=UTF-8']
|
||||
s.extra_rdoc_files = %w[README.markdown LICENSE]
|
||||
|
||||
s.add_runtime_dependency('liquid', '~> 2.6.1')
|
||||
s.add_runtime_dependency('liquid', '~> 3.0')
|
||||
s.add_runtime_dependency('kramdown', '~> 1.3')
|
||||
s.add_runtime_dependency('mercenary', '~> 0.3.3')
|
||||
s.add_runtime_dependency('safe_yaml', '~> 1.0')
|
||||
@@ -45,24 +45,4 @@ Gem::Specification.new do |s|
|
||||
s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0')
|
||||
s.add_runtime_dependency('jekyll-watch', '~> 1.1')
|
||||
s.add_runtime_dependency('classifier-reborn', '~> 2.0')
|
||||
|
||||
s.add_development_dependency('rake', '~> 10.1')
|
||||
s.add_development_dependency('rdoc', '~> 3.11')
|
||||
s.add_development_dependency('redgreen', '~> 1.2')
|
||||
s.add_development_dependency('shoulda', '~> 3.5')
|
||||
s.add_development_dependency('rr', '~> 1.1')
|
||||
s.add_development_dependency('cucumber', '1.3.11')
|
||||
s.add_development_dependency('RedCloth', '~> 4.2')
|
||||
s.add_development_dependency('maruku', '~> 0.7.0')
|
||||
s.add_development_dependency('rdiscount', '~> 1.6')
|
||||
s.add_development_dependency('launchy', '~> 2.3')
|
||||
s.add_development_dependency('simplecov', '~> 0.9')
|
||||
s.add_development_dependency('simplecov-gem-adapter', '~> 1.0.1')
|
||||
s.add_development_dependency('mime-types', '~> 1.5')
|
||||
s.add_development_dependency('activesupport', '~> 3.2.13')
|
||||
s.add_development_dependency('jekyll_test_plugin')
|
||||
s.add_development_dependency('jekyll_test_plugin_malicious')
|
||||
s.add_development_dependency('rouge', '~> 1.7')
|
||||
s.add_development_dependency('minitest') if RUBY_PLATFORM =~ /cygwin/
|
||||
s.add_development_dependency('test-unit') if RUBY_PLATFORM =~ /cygwin/
|
||||
end
|
||||
|
||||
@@ -21,6 +21,7 @@ require 'time'
|
||||
require 'English'
|
||||
require 'pathname'
|
||||
require 'logger'
|
||||
require 'set'
|
||||
|
||||
# 3rd party
|
||||
require 'safe_yaml/load'
|
||||
@@ -29,6 +30,7 @@ require 'kramdown'
|
||||
require 'colorator'
|
||||
|
||||
SafeYAML::OPTIONS[:suppress_warnings] = true
|
||||
Liquid::Template.error_mode = :strict
|
||||
|
||||
module Jekyll
|
||||
|
||||
@@ -43,11 +45,13 @@ module Jekyll
|
||||
autoload :EntryFilter, 'jekyll/entry_filter'
|
||||
autoload :Errors, 'jekyll/errors'
|
||||
autoload :Excerpt, 'jekyll/excerpt'
|
||||
autoload :External, 'jekyll/external'
|
||||
autoload :Filters, 'jekyll/filters'
|
||||
autoload :FrontmatterDefaults, 'jekyll/frontmatter_defaults'
|
||||
autoload :Layout, 'jekyll/layout'
|
||||
autoload :LayoutReader, 'jekyll/layout_reader'
|
||||
autoload :LogAdapter, 'jekyll/log_adapter'
|
||||
autoload :Metadata, 'jekyll/metadata'
|
||||
autoload :Page, 'jekyll/page'
|
||||
autoload :PluginManager, 'jekyll/plugin_manager'
|
||||
autoload :Post, 'jekyll/post'
|
||||
@@ -153,6 +157,9 @@ module Jekyll
|
||||
end
|
||||
end
|
||||
|
||||
# Conditional optimizations
|
||||
Jekyll::External.require_if_present('liquid-c')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -163,7 +170,7 @@ require_all 'jekyll/generators'
|
||||
require_all 'jekyll/tags'
|
||||
|
||||
# Eventually remove these for 3.0 as non-core
|
||||
Jekyll::Deprecator.gracefully_require(%w[
|
||||
Jekyll::External.require_with_graceful_fail(%w[
|
||||
toml
|
||||
jekyll-paginate
|
||||
jekyll-gist
|
||||
|
||||
@@ -13,6 +13,7 @@ module Jekyll
|
||||
# Cleans up the site's destination directory
|
||||
def cleanup!
|
||||
FileUtils.rm_rf(obsolete_files)
|
||||
FileUtils.rm_rf(metadata_file) if @site.full_rebuild?
|
||||
end
|
||||
|
||||
private
|
||||
@@ -24,6 +25,13 @@ module Jekyll
|
||||
(existing_files - new_files - new_dirs + replaced_files).to_a
|
||||
end
|
||||
|
||||
# Private: The metadata file storing dependency tree and build history
|
||||
#
|
||||
# Returns an Array with the metdata file as the only item
|
||||
def metadata_file
|
||||
[site.metadata.metadata_file]
|
||||
end
|
||||
|
||||
# Private: The list of existing files, apart from those included in keep_files and hidden files.
|
||||
#
|
||||
# Returns a Set with the file paths
|
||||
|
||||
@@ -40,7 +40,7 @@ module Jekyll
|
||||
if Utils.has_yaml_header? full_path
|
||||
doc = Jekyll::Document.new(full_path, { site: site, collection: self })
|
||||
doc.read
|
||||
docs << doc
|
||||
docs << doc if site.publisher.publish?(doc)
|
||||
else
|
||||
relative_dir = Jekyll.sanitized_path(relative_directory, File.dirname(file_path)).chomp("/.")
|
||||
files << StaticFile.new(site, site.source, relative_dir, File.basename(full_path), self)
|
||||
@@ -183,6 +183,5 @@ module Jekyll
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,6 +58,7 @@ module Jekyll
|
||||
c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished'
|
||||
c.option 'quiet', '-q', '--quiet', 'Silence output.'
|
||||
c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
|
||||
c.option 'full_rebuild', '-f', '--full-rebuild', 'Disable incremental rebuild.'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -50,8 +50,10 @@ module Jekyll
|
||||
def build(site, options)
|
||||
source = options['source']
|
||||
destination = options['destination']
|
||||
full_build = options['full_rebuild']
|
||||
Jekyll.logger.info "Source:", source
|
||||
Jekyll.logger.info "Destination:", destination
|
||||
Jekyll.logger.info "Incremental build:", (full_build ? "disabled" : "enabled")
|
||||
Jekyll.logger.info "Generating..."
|
||||
process_site(site)
|
||||
Jekyll.logger.info "", "done."
|
||||
@@ -64,7 +66,7 @@ module Jekyll
|
||||
#
|
||||
# Returns nothing.
|
||||
def watch(site, options)
|
||||
Deprecator.gracefully_require 'jekyll-watch'
|
||||
External.require_with_graceful_fail 'jekyll-watch'
|
||||
Jekyll::Watcher.watch(options)
|
||||
end
|
||||
|
||||
|
||||
42
lib/jekyll/commands/clean.rb
Normal file
42
lib/jekyll/commands/clean.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Clean < Command
|
||||
class << self
|
||||
|
||||
def init_with_program(prog)
|
||||
prog.command(:clean) do |c|
|
||||
c.syntax 'clean [subcommand]'
|
||||
c.description 'Clean the site (removes site output and metadata file) without building.'
|
||||
|
||||
c.action do |args, _|
|
||||
Jekyll::Commands::Clean.process({})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process(options)
|
||||
options = configuration_from_options(options)
|
||||
destination = options['destination']
|
||||
metadata_file = File.join(options['source'], '.jekyll-metadata')
|
||||
|
||||
if File.directory? destination
|
||||
Jekyll.logger.info "Cleaning #{destination}..."
|
||||
FileUtils.rm_rf(destination)
|
||||
Jekyll.logger.info "", "done."
|
||||
else
|
||||
Jekyll.logger.info "Nothing to do for #{destination}."
|
||||
end
|
||||
|
||||
if File.file? metadata_file
|
||||
Jekyll.logger.info "Removing #{metadata_file}..."
|
||||
FileUtils.rm_rf(metadata_file)
|
||||
Jekyll.logger.info "", "done."
|
||||
else
|
||||
Jekyll.logger.info "Nothing to do for #{metadata_file}."
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,30 +0,0 @@
|
||||
module Jekyll
|
||||
module Commands
|
||||
class Docs < Command
|
||||
|
||||
class << self
|
||||
|
||||
def init_with_program(prog)
|
||||
prog.command(:docs) do |c|
|
||||
c.syntax 'docs'
|
||||
c.description "Launch local server with docs for Jekyll v#{Jekyll::VERSION}"
|
||||
|
||||
c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
|
||||
c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
|
||||
|
||||
c.action do |args, options|
|
||||
options.merge!({
|
||||
'source' => File.expand_path("../../../site", File.dirname(__FILE__)),
|
||||
'destination' => File.expand_path("../../../site/_site", File.dirname(__FILE__))
|
||||
})
|
||||
Jekyll::Commands::Build.process(options)
|
||||
Jekyll::Commands::Serve.process(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -22,6 +22,7 @@ module Jekyll
|
||||
'encoding' => 'utf-8',
|
||||
'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md',
|
||||
'textile_ext' => 'textile',
|
||||
'full_rebuild' => false,
|
||||
|
||||
# Filtering Content
|
||||
'show_drafts' => nil,
|
||||
@@ -74,12 +75,12 @@ module Jekyll
|
||||
},
|
||||
|
||||
'kramdown' => {
|
||||
'auto_ids' => true,
|
||||
'footnote_nr' => 1,
|
||||
'entity_output' => 'as_char',
|
||||
'toc_levels' => '1..6',
|
||||
'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo',
|
||||
'use_coderay' => false,
|
||||
'auto_ids' => true,
|
||||
'footnote_nr' => 1,
|
||||
'entity_output' => 'as_char',
|
||||
'toc_levels' => '1..6',
|
||||
'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo',
|
||||
'enable_coderay' => false,
|
||||
|
||||
'coderay' => {
|
||||
'coderay_wrap' => 'div',
|
||||
@@ -253,6 +254,12 @@ module Jekyll
|
||||
config[option].map!(&:to_s)
|
||||
end
|
||||
|
||||
if (config['kramdown'] || {}).key?('use_coderay')
|
||||
Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" +
|
||||
" to 'enable_coderay' in your configuration file."
|
||||
config['kramdown']['use_coderay'] = config['kramdown'].delete('enable_coderay')
|
||||
end
|
||||
|
||||
if config.fetch('markdown', 'kramdown').to_s.downcase.eql?("maruku")
|
||||
Jekyll::Deprecator.deprecation_message "You're using the 'maruku' " +
|
||||
"Markdown processor. Maruku support has been deprecated and will " +
|
||||
|
||||
@@ -13,14 +13,14 @@ module Jekyll
|
||||
|
||||
def convert(content)
|
||||
# Check for use of coderay
|
||||
if @config['kramdown']['use_coderay']
|
||||
if @config['kramdown']['enable_coderay']
|
||||
%w[wrap line_numbers line_numbers_start tab_width bold_every css default_lang].each do |opt|
|
||||
key = "coderay_#{opt}"
|
||||
@config['kramdown'][key] = @config['kramdown']['coderay'][key] unless @config['kramdown'].key?(key)
|
||||
end
|
||||
end
|
||||
|
||||
Kramdown::Document.new(content, Utils.symbolize_hash_keys(@config["kramdown"])).to_html
|
||||
Kramdown::Document.new(content, Utils.symbolize_hash_keys(@config['kramdown'])).to_html
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ module Jekyll
|
||||
class Markdown
|
||||
class RDiscountParser
|
||||
def initialize(config)
|
||||
Jekyll::Deprecator.gracefully_require "rdiscount"
|
||||
Jekyll::External.require_with_graceful_fail "rdiscount"
|
||||
@config = config
|
||||
@rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ module Jekyll
|
||||
module WithPygments
|
||||
include CommonMethods
|
||||
def block_code(code, lang)
|
||||
Jekyll::Deprecator.gracefully_require("pygments")
|
||||
Jekyll::External.require_with_graceful_fail("pygments")
|
||||
lang = lang && lang.split.first || "text"
|
||||
add_code_tags(
|
||||
Pygments.highlight(code, :lexer => lang, :options => { :encoding => 'utf-8' }),
|
||||
@@ -55,7 +55,7 @@ module Jekyll
|
||||
|
||||
|
||||
def initialize(config)
|
||||
Deprecator.gracefully_require("redcarpet")
|
||||
External.require_with_graceful_fail("redcarpet")
|
||||
@config = config
|
||||
@redcarpet_extensions = {}
|
||||
@config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true }
|
||||
@@ -71,7 +71,7 @@ module Jekyll
|
||||
end
|
||||
when "rouge"
|
||||
Class.new(Redcarpet::Render::HTML) do
|
||||
Jekyll::Deprecator.gracefully_require(%w[
|
||||
Jekyll::External.require_with_graceful_fail(%w[
|
||||
rouge
|
||||
rouge/plugins/redcarpet
|
||||
])
|
||||
|
||||
@@ -168,6 +168,15 @@ module Jekyll
|
||||
true
|
||||
end
|
||||
|
||||
# Determine whether to regenerate the file based on metadata.
|
||||
#
|
||||
# Returns true if file needs to be regenerated
|
||||
def regenerate?
|
||||
asset_file? ||
|
||||
data['regenerate'] ||
|
||||
site.metadata.regenerate?(site.in_source_dir(relative_path))
|
||||
end
|
||||
|
||||
# Determine whether the file should be placed into layouts.
|
||||
#
|
||||
# Returns false if the document is an asset file.
|
||||
@@ -207,6 +216,12 @@ module Jekyll
|
||||
info,
|
||||
File.join(site.config['layouts'], layout.name))
|
||||
|
||||
# Add layout to dependency tree
|
||||
site.metadata.add_dependency(
|
||||
site.in_source_dir(path),
|
||||
site.in_source_dir(layout.path)
|
||||
)
|
||||
|
||||
if layout = layouts[layout.data["layout"]]
|
||||
if used.include?(layout)
|
||||
layout = nil # avoid recursive chain
|
||||
|
||||
@@ -40,22 +40,5 @@ module Jekyll
|
||||
Jekyll.logger.warn "Defaults:", "Please update your front-matter defaults to use 'type: #{current}'."
|
||||
end
|
||||
|
||||
def gracefully_require(gem_name)
|
||||
Array(gem_name).each do |name|
|
||||
begin
|
||||
require name
|
||||
rescue LoadError => e
|
||||
Jekyll.logger.error "Dependency Error:", <<-MSG
|
||||
Yikes! It looks like you don't have #{name} or one of its dependencies installed.
|
||||
In order to use Jekyll as currently configured, you'll need to install this gem.
|
||||
|
||||
The full error message from Ruby is: '#{e.message}'
|
||||
|
||||
If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/!
|
||||
MSG
|
||||
raise Errors::MissingDependencyException.new(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,6 +105,13 @@ module Jekyll
|
||||
!(coffeescript_file? || yaml_file?)
|
||||
end
|
||||
|
||||
# Determine whether the document should be regenerated based on metadata.
|
||||
#
|
||||
# Returns true if the document needs to be regenerated.
|
||||
def regenerate?
|
||||
data['regenerate'] || site.metadata.regenerate?(path, write?)
|
||||
end
|
||||
|
||||
# Determine whether the file should be placed into layouts.
|
||||
#
|
||||
# Returns false if the document is either an asset file or a yaml file,
|
||||
@@ -160,7 +167,7 @@ module Jekyll
|
||||
# Returns the full path to the output file of this document.
|
||||
def destination(base_directory)
|
||||
dest = site.in_dest_dir(base_directory)
|
||||
path = site.in_dest_dir(dest, url)
|
||||
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
||||
path = File.join(path, "index.html") if url =~ /\/$/
|
||||
path
|
||||
end
|
||||
@@ -233,8 +240,8 @@ module Jekyll
|
||||
Utils.deep_merge_hashes data, {
|
||||
"output" => output,
|
||||
"content" => content,
|
||||
"path" => path,
|
||||
"relative_path" => relative_path,
|
||||
"path" => relative_path,
|
||||
"url" => url,
|
||||
"collection" => collection.label
|
||||
}
|
||||
|
||||
59
lib/jekyll/external.rb
Normal file
59
lib/jekyll/external.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
module Jekyll
|
||||
module External
|
||||
class << self
|
||||
|
||||
#
|
||||
# Gems that, if installed, should be loaded.
|
||||
# Usually contain subcommands.
|
||||
#
|
||||
def blessed_gems
|
||||
%w{
|
||||
jekyll-docs
|
||||
jekyll-import
|
||||
}
|
||||
end
|
||||
|
||||
#
|
||||
# Require a gem or file if it's present, otherwise silently fail.
|
||||
#
|
||||
# names - a string gem name or array of gem names
|
||||
#
|
||||
def require_if_present(names)
|
||||
Array(names).each do |name|
|
||||
begin
|
||||
require name
|
||||
rescue LoadError
|
||||
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Require a gem or gems. If it's not present, show a very nice error
|
||||
# message that explains everything and is much more helpful than the
|
||||
# normal LoadError.
|
||||
#
|
||||
# names - a string gem name or array of gem names
|
||||
#
|
||||
def require_with_graceful_fail(names)
|
||||
Array(names).each do |name|
|
||||
begin
|
||||
require name
|
||||
rescue LoadError => e
|
||||
Jekyll.logger.error "Dependency Error:", <<-MSG
|
||||
Yikes! It looks like you don't have #{name} or one of its dependencies installed.
|
||||
In order to use Jekyll as currently configured, you'll need to install this gem.
|
||||
|
||||
The full error message from Ruby is: '#{e.message}'
|
||||
|
||||
If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/!
|
||||
MSG
|
||||
raise Jekyll::Errors::MissingDependencyException.new(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@ module Jekyll
|
||||
# Returns the HTML formatted String.
|
||||
def textilize(input)
|
||||
site = @context.registers[:site]
|
||||
converter = site.getConverterImpl(Jekyll::Converters::Textile)
|
||||
converter = site.find_converter_instance(Jekyll::Converters::Textile)
|
||||
converter.convert(input)
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ module Jekyll
|
||||
# Returns the HTML formatted String.
|
||||
def markdownify(input)
|
||||
site = @context.registers[:site]
|
||||
converter = site.getConverterImpl(Jekyll::Converters::Markdown)
|
||||
converter = site.find_converter_instance(Jekyll::Converters::Markdown)
|
||||
converter.convert(input)
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ module Jekyll
|
||||
# Returns the CSS formatted String.
|
||||
def sassify(input)
|
||||
site = @context.registers[:site]
|
||||
converter = site.getConverterImpl(Jekyll::Converters::Sass)
|
||||
converter = site.find_converter_instance(Jekyll::Converters::Sass)
|
||||
converter.convert(input)
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ module Jekyll
|
||||
# Returns the CSS formatted String.
|
||||
def scssify(input)
|
||||
site = @context.registers[:site]
|
||||
converter = site.getConverterImpl(Jekyll::Converters::Scss)
|
||||
converter = site.find_converter_instance(Jekyll::Converters::Scss)
|
||||
converter.convert(input)
|
||||
end
|
||||
|
||||
@@ -309,7 +309,7 @@ module Jekyll
|
||||
else
|
||||
Jekyll.logger.error "Invalid Date:", "'#{input}' is not a valid datetime."
|
||||
exit(1)
|
||||
end
|
||||
end.localtime
|
||||
end
|
||||
|
||||
def groupable?(element)
|
||||
|
||||
@@ -8,6 +8,9 @@ module Jekyll
|
||||
# Gets the name of this layout.
|
||||
attr_reader :name
|
||||
|
||||
# Gets the path to this layout.
|
||||
attr_reader :path
|
||||
|
||||
# Gets/Sets the extension of this layout.
|
||||
attr_accessor :ext
|
||||
|
||||
@@ -26,6 +29,7 @@ module Jekyll
|
||||
@site = site
|
||||
@base = base
|
||||
@name = name
|
||||
@path = site.in_source_dir(base, name)
|
||||
|
||||
self.data = {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Jekyll
|
||||
class LogAdapter
|
||||
attr_reader :writer
|
||||
attr_reader :writer, :messages
|
||||
|
||||
LOG_LEVELS = {
|
||||
:debug => ::Logger::DEBUG,
|
||||
@@ -16,6 +16,7 @@ module Jekyll
|
||||
#
|
||||
# Returns nothing
|
||||
def initialize(writer, level = :info)
|
||||
@messages = []
|
||||
@writer = writer
|
||||
self.log_level = level
|
||||
end
|
||||
@@ -87,7 +88,9 @@ module Jekyll
|
||||
#
|
||||
# Returns the formatted message
|
||||
def message(topic, message)
|
||||
formatted_topic(topic) + message.to_s.gsub(/\s+/, ' ')
|
||||
msg = formatted_topic(topic) + message.to_s.gsub(/\s+/, ' ')
|
||||
messages << msg
|
||||
msg
|
||||
end
|
||||
|
||||
# Internal: Format the topic
|
||||
|
||||
121
lib/jekyll/metadata.rb
Normal file
121
lib/jekyll/metadata.rb
Normal file
@@ -0,0 +1,121 @@
|
||||
module Jekyll
|
||||
class Metadata
|
||||
attr_reader :site, :metadata, :cache
|
||||
|
||||
def initialize(site)
|
||||
@site = site
|
||||
|
||||
# Read metadata from file
|
||||
read_metadata
|
||||
|
||||
# Initialize cache to an empty hash
|
||||
@cache = {}
|
||||
end
|
||||
|
||||
# Add a path to the metadata
|
||||
#
|
||||
# Returns true, also on failure.
|
||||
def add(path)
|
||||
return true unless File.exist?(path)
|
||||
|
||||
metadata[path] = {
|
||||
"mtime" => File.mtime(path),
|
||||
"deps" => []
|
||||
}
|
||||
cache[path] = true
|
||||
end
|
||||
|
||||
# Force a path to regenerate
|
||||
#
|
||||
# Returns true.
|
||||
def force(path)
|
||||
cache[path] = true
|
||||
end
|
||||
|
||||
# Clear the metadata and cache
|
||||
#
|
||||
# Returns nothing
|
||||
def clear
|
||||
@metadata = {}
|
||||
@cache = {}
|
||||
end
|
||||
|
||||
# Checks if a path should be regenerated
|
||||
#
|
||||
# Returns a boolean.
|
||||
def regenerate?(path, add = true)
|
||||
return true if disabled?
|
||||
|
||||
# Check for path in cache
|
||||
if cache.has_key? path
|
||||
return cache[path]
|
||||
end
|
||||
|
||||
# Check path that exists in metadata
|
||||
data = metadata[path]
|
||||
if data
|
||||
data["deps"].each do |dependency|
|
||||
if regenerate?(dependency)
|
||||
return cache[dependency] = cache[path] = true
|
||||
end
|
||||
end
|
||||
if data["mtime"].eql? File.mtime(path)
|
||||
return cache[path] = false
|
||||
else
|
||||
return !add || add(path)
|
||||
end
|
||||
end
|
||||
|
||||
# Path does not exist in metadata, add it
|
||||
return !add || add(path)
|
||||
end
|
||||
|
||||
# Add a dependency of a path
|
||||
#
|
||||
# Returns nothing.
|
||||
def add_dependency(path, dependency)
|
||||
return if (metadata[path].nil? || @disabled)
|
||||
|
||||
metadata[path]["deps"] << dependency unless metadata[path]["deps"].include? dependency
|
||||
regenerate? dependency
|
||||
end
|
||||
|
||||
# Write the metadata to disk
|
||||
#
|
||||
# Returns nothing.
|
||||
def write
|
||||
File.open(metadata_file, 'w') do |f|
|
||||
f.write(metadata.to_yaml)
|
||||
end
|
||||
end
|
||||
|
||||
# Produce the absolute path of the metadata file
|
||||
#
|
||||
# Returns the String path of the file.
|
||||
def metadata_file
|
||||
site.in_source_dir('.jekyll-metadata')
|
||||
end
|
||||
|
||||
# Check if metadata has been disabled
|
||||
#
|
||||
# Returns a Boolean (true for disabled, false for enabled).
|
||||
def disabled?
|
||||
@disabled = site.full_rebuild? if @disabled.nil?
|
||||
@disabled
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Read metadata from the metadata file, if no file is found,
|
||||
# initialize with an empty hash
|
||||
#
|
||||
# Returns the read metadata.
|
||||
def read_metadata
|
||||
@metadata = if !disabled? && File.file?(metadata_file)
|
||||
SafeYAML.load(File.read(metadata_file))
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,11 +3,12 @@
|
||||
module Jekyll
|
||||
class Renderer
|
||||
|
||||
attr_reader :document, :site
|
||||
attr_reader :document, :site, :site_payload
|
||||
|
||||
def initialize(site, document)
|
||||
@site = site
|
||||
@document = document
|
||||
def initialize(site, document, site_payload = nil)
|
||||
@site = site
|
||||
@document = document
|
||||
@site_payload = site_payload
|
||||
end
|
||||
|
||||
# Determine which converters to use based on this document's
|
||||
@@ -32,7 +33,7 @@ module Jekyll
|
||||
def run
|
||||
payload = Utils.deep_merge_hashes({
|
||||
"page" => document.to_liquid
|
||||
}, site.site_payload)
|
||||
}, site_payload || site.site_payload)
|
||||
|
||||
info = {
|
||||
filters: [Jekyll::Filters],
|
||||
@@ -138,6 +139,12 @@ module Jekyll
|
||||
File.join(site.config['layouts'], layout.name)
|
||||
)
|
||||
|
||||
# Add layout to dependency tree
|
||||
site.metadata.add_dependency(
|
||||
site.in_source_dir(document.path),
|
||||
site.in_source_dir(layout.path)
|
||||
) if document.write?
|
||||
|
||||
if layout = site.layouts[layout.data["layout"]]
|
||||
if used.include?(layout)
|
||||
layout = nil # avoid recursive chain
|
||||
|
||||
@@ -11,6 +11,7 @@ module Jekyll
|
||||
:gems, :plugin_manager
|
||||
|
||||
attr_accessor :converters, :generators
|
||||
attr_reader :metadata
|
||||
|
||||
# Public: Initialize a new Site.
|
||||
#
|
||||
@@ -27,6 +28,9 @@ module Jekyll
|
||||
@source = File.expand_path(config['source']).freeze
|
||||
@dest = File.expand_path(config['destination']).freeze
|
||||
|
||||
# Build metadata
|
||||
@metadata = Metadata.new(self)
|
||||
|
||||
self.plugin_manager = Jekyll::PluginManager.new(self)
|
||||
self.plugins = plugin_manager.plugins_path
|
||||
|
||||
@@ -183,6 +187,7 @@ module Jekyll
|
||||
end
|
||||
|
||||
pages.sort_by!(&:name)
|
||||
static_files.sort_by!(&:relative_path)
|
||||
end
|
||||
|
||||
# Read all the files in <source>/<dir>/_posts and create a new Post
|
||||
@@ -287,15 +292,16 @@ module Jekyll
|
||||
def render
|
||||
relative_permalinks_deprecation_method
|
||||
|
||||
payload = site_payload
|
||||
collections.each do |label, collection|
|
||||
collection.docs.each do |document|
|
||||
document.output = Jekyll::Renderer.new(self, document).run
|
||||
document.output = Jekyll::Renderer.new(self, document, payload).run if document.regenerate?
|
||||
end
|
||||
end
|
||||
|
||||
payload = site_payload
|
||||
[posts, pages].flatten.each do |page_or_post|
|
||||
page_or_post.render(layouts, payload)
|
||||
page_or_post.render(layouts, payload) if page_or_post.regenerate?
|
||||
end
|
||||
rescue Errno::ENOENT => e
|
||||
# ignore missing layout dir
|
||||
@@ -312,7 +318,10 @@ module Jekyll
|
||||
#
|
||||
# Returns nothing.
|
||||
def write
|
||||
each_site_file { |item| item.write(dest) }
|
||||
each_site_file { |item|
|
||||
item.write(dest) if item.regenerate?
|
||||
}
|
||||
metadata.write unless full_rebuild?
|
||||
end
|
||||
|
||||
# Construct a Hash of Posts indexed by the specified Post attribute.
|
||||
@@ -377,7 +386,7 @@ module Jekyll
|
||||
"time" => time,
|
||||
"posts" => posts.sort { |a, b| b <=> a },
|
||||
"pages" => pages,
|
||||
"static_files" => static_files.sort { |a, b| a.relative_path <=> b.relative_path },
|
||||
"static_files" => static_files,
|
||||
"html_pages" => pages.select { |page| page.html? || page.url.end_with?("/") },
|
||||
"categories" => post_attr_hash('categories'),
|
||||
"tags" => post_attr_hash('tags'),
|
||||
@@ -405,13 +414,8 @@ module Jekyll
|
||||
# klass - The Class of the Converter to fetch.
|
||||
#
|
||||
# Returns the Converter instance implementing the given Converter.
|
||||
def getConverterImpl(klass)
|
||||
matches = converters.select { |c| c.class == klass }
|
||||
if impl = matches.first
|
||||
impl
|
||||
else
|
||||
raise "Converter implementation not found for #{klass}"
|
||||
end
|
||||
def find_converter_instance(klass)
|
||||
converters.find { |c| c.class == klass } || proc { raise "No converter for #{klass}" }.call
|
||||
end
|
||||
|
||||
# Create array of instances of the subclasses of the class or module
|
||||
@@ -453,7 +457,7 @@ module Jekyll
|
||||
|
||||
def relative_permalinks_deprecation_method
|
||||
if config['relative_permalinks'] && has_relative_page?
|
||||
Jekyll.logger.warn "Deprecation:", "Starting in 2.0, permalinks for pages" +
|
||||
Jekyll.logger.warn "Deprecation:", "Since v2.0, permalinks for pages" +
|
||||
" in subfolders must be relative to the" +
|
||||
" site source directory, not the parent" +
|
||||
" directory. Check http://jekyllrb.com/docs/upgrading/"+
|
||||
@@ -483,6 +487,17 @@ module Jekyll
|
||||
@frontmatter_defaults ||= FrontmatterDefaults.new(self)
|
||||
end
|
||||
|
||||
# Whether to perform a full rebuild without metadata
|
||||
#
|
||||
# Returns a Boolean: true for a full rebuild, false for normal build
|
||||
def full_rebuild?(override = {})
|
||||
override['full_rebuild'] || config['full_rebuild']
|
||||
end
|
||||
|
||||
def publisher
|
||||
@publisher ||= Publisher.new(self)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def has_relative_page?
|
||||
@@ -503,9 +518,5 @@ module Jekyll
|
||||
name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
|
||||
name.gsub(/\s+/, '_')
|
||||
end
|
||||
|
||||
def publisher
|
||||
@publisher ||= Publisher.new(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,8 @@ module Jekyll
|
||||
# The cache of last modification times [path] -> mtime.
|
||||
@@mtimes = Hash.new
|
||||
|
||||
attr_reader :relative_path
|
||||
|
||||
# Initialize a new StaticFile.
|
||||
#
|
||||
# site - The Site.
|
||||
@@ -15,6 +17,7 @@ module Jekyll
|
||||
@dir = dir
|
||||
@name = name
|
||||
@collection = collection
|
||||
@relative_path = File.join(*[@dir, @name].compact)
|
||||
end
|
||||
|
||||
# Returns source file path.
|
||||
@@ -22,11 +25,6 @@ module Jekyll
|
||||
File.join(*[@base, @dir, @name].compact)
|
||||
end
|
||||
|
||||
# Returns the source file path relative to the site source
|
||||
def relative_path
|
||||
@relative_path ||= File.join(*[@dir, @name].compact)
|
||||
end
|
||||
|
||||
def extname
|
||||
File.extname(path)
|
||||
end
|
||||
@@ -67,6 +65,8 @@ module Jekyll
|
||||
true
|
||||
end
|
||||
|
||||
alias_method :regenerate?, :write?
|
||||
|
||||
# Write the static file to the destination directory (if modified).
|
||||
#
|
||||
# dest - The String path to the destination dir.
|
||||
|
||||
@@ -18,6 +18,12 @@ module Jekyll
|
||||
VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/
|
||||
VARIABLE_SYNTAX = /(?<variable>[^{]*\{\{\s*(?<name>[\w\-\.]+)\s*(\|.*)?\}\}[^\s}]*)(?<params>.*)/
|
||||
|
||||
class << self
|
||||
def source_cache
|
||||
@@source_cache ||= {}
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
super
|
||||
@includes_dir = tag_includes_dir
|
||||
@@ -105,13 +111,22 @@ eos
|
||||
end
|
||||
|
||||
def render(context)
|
||||
site = context.registers[:site]
|
||||
dir = resolved_includes_dir(context)
|
||||
|
||||
file = render_variable(context) || @file
|
||||
validate_file_name(file)
|
||||
|
||||
path = File.join(dir, file)
|
||||
validate_path(path, dir, context.registers[:site].safe)
|
||||
validate_path(path, dir, site.safe)
|
||||
|
||||
# Add include to dependency tree
|
||||
if context.registers[:page] and context.registers[:page].has_key? "path"
|
||||
site.metadata.add_dependency(
|
||||
site.in_source_dir(context.registers[:page]["path"]),
|
||||
path
|
||||
)
|
||||
end
|
||||
|
||||
begin
|
||||
partial = Liquid::Template.parse(source(path, context))
|
||||
@@ -147,7 +162,7 @@ eos
|
||||
|
||||
# This method allows to modify the file content by inheriting from the class.
|
||||
def source(file, context)
|
||||
File.read(file, file_read_opts(context))
|
||||
self.class.source_cache[file] ||= File.read(file, file_read_opts(context))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ module Jekyll
|
||||
# Returns the parsed date if successful, throws a FatalException
|
||||
# if not
|
||||
def parse_date(input, msg = "Input could not be parsed.")
|
||||
Time.parse(input)
|
||||
Time.parse(input).localtime
|
||||
rescue ArgumentError
|
||||
raise Errors::FatalException.new("Invalid date '#{input}': " + msg)
|
||||
end
|
||||
@@ -113,7 +113,7 @@ module Jekyll
|
||||
unless string.nil?
|
||||
string \
|
||||
# Replace each non-alphanumeric character sequence with a hyphen
|
||||
.gsub(/[^a-z0-9]+/i, '-') \
|
||||
.gsub(/[^[:alnum:]]+/i, '-') \
|
||||
# Remove leading/trailing hyphen
|
||||
.gsub(/^\-|\-$/i, '') \
|
||||
# Downcase it
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
|
||||
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
|
||||
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" />
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
|
||||
</head>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
<div class="post">
|
||||
<article class="post">
|
||||
|
||||
<header class="post-header">
|
||||
<h1 class="post-title">{{ page.title }}</h1>
|
||||
</header>
|
||||
|
||||
<article class="post-content">
|
||||
<div class="post-content">
|
||||
{{ content }}
|
||||
</article>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
<div class="post">
|
||||
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
|
||||
|
||||
<header class="post-header">
|
||||
<h1 class="post-title">{{ page.title }}</h1>
|
||||
<p class="post-meta">{{ page.date | date: "%b %-d, %Y" }}{% if page.author %} • {{ page.author }}{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</p>
|
||||
<h1 class="post-title" itemprop="name headline">{{ page.title }}</h1>
|
||||
<p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</p>
|
||||
</header>
|
||||
|
||||
<article class="post-content">
|
||||
<div class="post-content" itemprop="articleBody">
|
||||
{{ content }}
|
||||
</article>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
color: $text-color;
|
||||
line-height: $base-line-height;
|
||||
|
||||
// Gaps between nav items, but not on the first one
|
||||
&:not(:first-child) {
|
||||
margin-left: 20px;
|
||||
// Gaps between nav items, but not on the last one
|
||||
&:not(:last-child) {
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
script/branding
|
||||
bundle install
|
||||
bundle install -j8
|
||||
|
||||
@@ -6,11 +6,11 @@ export BENCHMARK=true
|
||||
command -v stackprof > /dev/null || script/bootstrap
|
||||
|
||||
TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site'})"
|
||||
PROF_OUTPUT_FILE=tmp/stackprof-$(date +%Y%m%d).dump
|
||||
PROF_OUTPUT_FILE=tmp/stackprof-$(date +%Y%m%d%H%M).dump
|
||||
|
||||
test -f "$PROF_OUTPUT_FILE" || {
|
||||
bundle exec ruby -r./lib/jekyll -rstackprof \
|
||||
-e "StackProf.run(mode: :cpu, out: '${PROF_OUTPUT_FILE}') { ${TEST_SCRIPT} }"
|
||||
-e "StackProf.run(mode: :cpu, interval: 100, out: '${PROF_OUTPUT_FILE}') { ${TEST_SCRIPT} }"
|
||||
}
|
||||
|
||||
bundle exec stackprof $PROF_OUTPUT_FILE $@
|
||||
|
||||
10
script/test
10
script/test
@@ -10,7 +10,15 @@ else
|
||||
TEST_FILES="$@"
|
||||
fi
|
||||
|
||||
RAKE_LIB_DIR=$(ruby -e "puts Gem::Specification.find_by_name('rake').gem_dir + '/lib'")
|
||||
# bundle exec gem env
|
||||
GEM_DIR=$(bundle exec gem env | grep -C 1 "GEM PATHS" | tail -1 | cut -d '-' -f2 | cut -d' ' -f2)
|
||||
RAKE_LIB_WITH_VERSION=$(bundle exec ruby -e "puts Gem::Specification.find_by_name('rake').gem_dir.split('/').last + '/lib'")
|
||||
RAKE_LIB_DIR="${GEM_DIR}/gems/${RAKE_LIB_WITH_VERSION}"
|
||||
|
||||
test -d "${RAKE_LIB_DIR}" || {
|
||||
echo "No ${RAKE_LIB_DIR}. Installing Rake."
|
||||
bundle show rake | cut -d'/' -f12 | cut -d'-' -f 2 | xargs bundle exec gem install rake -v
|
||||
}
|
||||
|
||||
set -x
|
||||
|
||||
|
||||
@@ -497,7 +497,7 @@ excerpt_separator: "\n\n"
|
||||
# Serving
|
||||
detach: false
|
||||
port: 4000
|
||||
host: 0.0.0.0
|
||||
host: 127.0.0.1
|
||||
baseurl: "" # does not include hostname
|
||||
|
||||
# Backwards-compatibility
|
||||
@@ -527,12 +527,12 @@ redcarpet:
|
||||
extensions: []
|
||||
|
||||
kramdown:
|
||||
auto_ids: true
|
||||
footnote_nr: 1
|
||||
entity_output: as_char
|
||||
toc_levels: 1..6
|
||||
smart_quotes: lsquo,rsquo,ldquo,rdquo
|
||||
use_coderay: false
|
||||
auto_ids: true
|
||||
footnote_nr: 1
|
||||
entity_output: as_char
|
||||
toc_levels: 1..6
|
||||
smart_quotes: lsquo,rsquo,ldquo,rdquo
|
||||
enable_coderay: false
|
||||
|
||||
coderay:
|
||||
coderay_wrap: div
|
||||
|
||||
@@ -60,7 +60,7 @@ and associated URLs might look like:
|
||||
|
||||
### Named folders containing index HTML files
|
||||
|
||||
There is nothing wrong with the above method, however some people like to keep
|
||||
There is nothing wrong with the above method. However, some people like to keep
|
||||
their URLs free from things like filename extensions. To achieve clean URLs for
|
||||
pages using Jekyll, you simply need to create a folder for each top-level page
|
||||
you want, and then place an `index.html` file in each page’s folder. This way
|
||||
|
||||
@@ -32,7 +32,7 @@ paginate: 5
|
||||
The number should be the maximum number of Posts you’d like to be displayed per-
|
||||
page in the generated site.
|
||||
|
||||
You may also specify where the destination of the pagination pages:
|
||||
You may also specify the destination of the pagination pages:
|
||||
|
||||
{% highlight yaml %}
|
||||
paginate_path: "blog/page:num/"
|
||||
|
||||
@@ -13,8 +13,8 @@ having to modify the Jekyll source itself.
|
||||
<div class="note info">
|
||||
<h5>Plugins on GitHub Pages</h5>
|
||||
<p>
|
||||
<a href="http://pages.github.com/">GitHub Pages</a> is powered by Jekyll,
|
||||
however all Pages sites are generated using the <code>--safe</code> option
|
||||
<a href="http://pages.github.com/">GitHub Pages</a> is powered by Jekyll.
|
||||
However, all Pages sites are generated using the <code>--safe</code> option
|
||||
to disable custom plugins for security reasons. Unfortunately, this means
|
||||
your plugins won’t work if you’re deploying to GitHub Pages.<br><br>
|
||||
You can still use GitHub Pages to publish your site, but you’ll need to
|
||||
@@ -66,11 +66,8 @@ based on your own rules.
|
||||
|
||||
A generator is a subclass of `Jekyll::Generator` that defines a `generate`
|
||||
method, which receives an instance of
|
||||
[`Jekyll::Site`]({{ site.repository }}/blob/master/lib/jekyll/site.rb).
|
||||
|
||||
Generation is triggered for its side-effects, the return value of `generate` is
|
||||
ignored. Jekyll does not assume any particular side-effect to happen, it just
|
||||
runs the method.
|
||||
[`Jekyll::Site`]({{ site.repository }}/blob/master/lib/jekyll/site.rb). The
|
||||
return value of `generate` is ignored.
|
||||
|
||||
Generators run after Jekyll has made an inventory of the existing content, and
|
||||
before the site is generated. Pages with YAML Front Matters are stored as
|
||||
@@ -534,6 +531,7 @@ You can find a few useful plugins at the following locations:
|
||||
- [Jekyll-Ordinal](https://github.com/PatrickC8t/Jekyll-Ordinal): Jekyll liquid filter to output a date ordinal such as "st", "nd", "rd", or "th".
|
||||
- [Deprecated articles keeper](https://github.com/kzykbys/JekyllPlugins) by [Kazuya Kobayashi](http://blog.kazuya.co/): A simple Jekyll filter which monitor how old an article is.
|
||||
- [Jekyll-jalali](https://github.com/mehdisadeghi/jekyll-jalali) by [Mehdi Sadeghi](http://mehdix.ir): A simple Gregorian to Jalali date converter filter.
|
||||
- [Jekyll Thumbnail Filter](https://github.com/matallo/jekyll-thumbnail-filter): Related posts thumbnail filter.
|
||||
|
||||
#### Tags
|
||||
|
||||
|
||||
@@ -38,9 +38,11 @@ Jekyll’s growing use is producing a wide variety of tutorials, frameworks, ext
|
||||
> “Jekyll is everything that I ever wanted in a blogging engine. Really. It isn’t perfect, but what’s excellent about it is that if there’s something wrong, I know exactly how it works and how to fix it. It runs on the your machine only, and is essentially an added”build" step between you and the browser. I coded this entire site in TextMate using standard HTML5 and CSS3, and then at the end I added just a few little variables to the markup. Presto-chango, my site is built and I am at peace with the world.”
|
||||
- [‘Build A Blog With Jekyll And GitHub Pages’, by Barry Clark](http://www.smashingmagazine.com/2014/08/01/build-blog-jekyll-github-pages/)
|
||||
> “I recently migrated my blog from WordPress to Jekyll, a fantastic website generator that’s designed for building minimal, static blogs to be hosted on GitHub Pages. The simplicity of Jekyll’s theming layer and writing workflow is fantastic; however, setting up my website took a lot longer than expected. In this article we'll walk through: the quickest way to set up a Jekyll powered blog, how to avoid common problems with using Jekyll, how to import your content from Wordpress, and more.”
|
||||
- [Generating a Tag Cloud in Jekyll](http://www.justkez.com/generating-a-tag-cloud-in-jekyll/)
|
||||
- [Generating a Tag Cloud in Jekyll](http://www.justkez.com/generating-a-tag-cloud-in-jekyll/)
|
||||
A guide to implementing a tag cloud and per-tag content pages using Jekyll.
|
||||
|
||||
- A way to [extend Jekyll](https://github.com/rfelix/jekyll_ext) without forking and modifying the Jekyll gem codebase and some [portable Jekyll extensions](https://wiki.github.com/rfelix/jekyll_ext/extensions) that can be reused and shared.
|
||||
|
||||
- [Using your Rails layouts in Jekyll](http://numbers.brighterplanet.com/2010/08/09/sharing-rails-views-with-jekyll)
|
||||
- [Adding Ajax pagination to Jekyll](http://eduardoboucas.com/blog/2014/11/10/adding-ajax-pagination-to-jekyll.html)
|
||||
- [Using Jekyll’s Data Files to build a dynamic navbar](http://www.jordanthornque.st/blog/building-dynamic-navbars-with-jekyll/)
|
||||
|
||||
@@ -303,7 +303,7 @@ You can also choose to include file fragments relative to the current file:
|
||||
You won't need to place your included content within the `_includes` directory. Instead,
|
||||
the inclusion is specifically relative to the file where the tag is being used. For example,
|
||||
if `_posts/2014-09-03-my-file.markdown` uses the `include_relative` tag, the included file
|
||||
must be within the `_posts` directory, or one of it's subdirectories. You cannot include
|
||||
must be within the `_posts` directory, or one of its subdirectories. You cannot include
|
||||
files in other locations.
|
||||
|
||||
All the other capabilities of the `include` tag are available to the `include_relative` tag,
|
||||
|
||||
@@ -81,4 +81,7 @@ $ jekyll build --source _source --destination _deploy
|
||||
{% endhighlight %}
|
||||
|
||||
For more about the possible configuration options, see the
|
||||
[configuration](../configuration/) page.
|
||||
[configuration](../configuration/) page.
|
||||
|
||||
If you're interested in browsing these docs on-the-go, install the
|
||||
`jekyll-docs` gem and run `jekyll docs` in your terminal.
|
||||
|
||||
@@ -35,7 +35,8 @@ class Test::Unit::TestCase
|
||||
def site_configuration(overrides = {})
|
||||
full_overrides = build_configs(overrides, build_configs({"destination" => dest_dir}))
|
||||
build_configs({
|
||||
"source" => source_dir,
|
||||
"source" => source_dir,
|
||||
"full_rebuild" => true
|
||||
}, full_overrides)
|
||||
end
|
||||
|
||||
@@ -49,6 +50,7 @@ class Test::Unit::TestCase
|
||||
|
||||
def clear_dest
|
||||
FileUtils.rm_rf(dest_dir)
|
||||
FileUtils.rm_rf(source_dir('.jekyll-metadata'))
|
||||
end
|
||||
|
||||
def test_dir(*subdirs)
|
||||
|
||||
5
test/source/_methods/escape-+ #%20[].md
Normal file
5
test/source/_methods/escape-+ #%20[].md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
title: "Jekyll.escape"
|
||||
---
|
||||
|
||||
Signs are nice
|
||||
7
test/source/_slides/non-outputted-slide.html
Normal file
7
test/source/_slides/non-outputted-slide.html
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Non outputted slide
|
||||
layout: slide
|
||||
published: false
|
||||
---
|
||||
|
||||
This should not be output
|
||||
@@ -138,6 +138,7 @@ class TestCollections < Test::Unit::TestCase
|
||||
_methods/site/generate.md
|
||||
_methods/site/initialize.md
|
||||
_methods/um_hi.md
|
||||
_methods/escape-+\ #%20[].md
|
||||
], doc.relative_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,6 +48,10 @@ class TestDocument < Test::Unit::TestCase
|
||||
assert_equal @document.to_liquid['collection'], "methods"
|
||||
end
|
||||
|
||||
should "output its relative path as path in Liquid" do
|
||||
assert_equal @document.to_liquid['path'], "_methods/configuration.md"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "a document as part of a collection with frontmatter defaults" do
|
||||
@@ -237,7 +241,7 @@ class TestDocument < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "a static file in a collection" do
|
||||
context "documents in a collection" do
|
||||
setup do
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"collections" => {
|
||||
@@ -249,6 +253,35 @@ class TestDocument < Test::Unit::TestCase
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
@site.process
|
||||
@files = @site.collections["slides"].docs
|
||||
end
|
||||
|
||||
context "without output overrides" do
|
||||
should "be output according to collection defaults" do
|
||||
assert_not_nil @files.find { |doc| doc.relative_path == "_slides/example-slide-4.html" }
|
||||
end
|
||||
end
|
||||
|
||||
context "with output overrides" do
|
||||
should "be output according its front matter" do
|
||||
assert_nil @files.find { |doc| doc.relative_path == "_slides/non-outputted-slide.html" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "a static file in a collection" do
|
||||
setup do
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"collections" => {
|
||||
"slides" => {
|
||||
"output" => true
|
||||
}
|
||||
},
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir,
|
||||
"full_rebuild" => true
|
||||
}))
|
||||
@site.process
|
||||
@document = @site.collections["slides"].files.find { |doc| doc.relative_path == "_slides/octojekyll.png" }
|
||||
@dest_file = dest_dir("slides/octojekyll.png")
|
||||
end
|
||||
@@ -270,4 +303,34 @@ class TestDocument < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "a document in a collection with non-alphabetic file name" do
|
||||
setup do
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"collections" => {
|
||||
"methods" => {
|
||||
"output" => true
|
||||
}
|
||||
},
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
@site.process
|
||||
@document = @site.collections["methods"].docs.find { |doc| doc.relative_path == "_methods/escape-+ #%20[].md" }
|
||||
@dest_file = dest_dir("methods/escape-+ #%20[].html")
|
||||
end
|
||||
|
||||
should "produce the right URL" do
|
||||
assert_equal "/methods/escape-+%20%23%2520%5B%5D.html", @document.url
|
||||
end
|
||||
|
||||
should "produce the right destination" do
|
||||
assert_equal @dest_file, @document.destination(dest_dir)
|
||||
end
|
||||
|
||||
should "be output in the correct place" do
|
||||
assert_equal true, File.file?(@dest_file)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -72,11 +72,11 @@ class TestFilters < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
should "format a time with xmlschema" do
|
||||
assert_equal "2013-03-27T11:22:33Z", @filter.date_to_xmlschema(@sample_time)
|
||||
assert_equal "2013-03-27T11:22:33+00:00", @filter.date_to_xmlschema(@sample_time)
|
||||
end
|
||||
|
||||
should "format a time according to RFC-822" do
|
||||
assert_equal "Wed, 27 Mar 2013 11:22:33 -0000", @filter.date_to_rfc822(@sample_time)
|
||||
assert_equal "Wed, 27 Mar 2013 11:22:33 +0000", @filter.date_to_rfc822(@sample_time)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -90,11 +90,11 @@ class TestFilters < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
should "format a time with xmlschema" do
|
||||
assert_equal "2001-09-11T12:46:30Z", @filter.date_to_xmlschema(@time_as_string)
|
||||
assert_equal "2001-09-11T12:46:30+00:00", @filter.date_to_xmlschema(@time_as_string)
|
||||
end
|
||||
|
||||
should "format a time according to RFC-822" do
|
||||
assert_equal "Tue, 11 Sep 2001 12:46:30 -0000", @filter.date_to_rfc822(@time_as_string)
|
||||
assert_equal "Tue, 11 Sep 2001 12:46:30 +0000", @filter.date_to_rfc822(@time_as_string)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class TestKramdown < Test::Unit::TestCase
|
||||
'toc_levels' => '1..6',
|
||||
'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo',
|
||||
|
||||
'use_coderay' => true,
|
||||
'enable_coderay' => true,
|
||||
'coderay_bold_every'=> 12,
|
||||
'coderay' => {
|
||||
'coderay_css' => :style,
|
||||
|
||||
@@ -3,6 +3,11 @@ require 'helper'
|
||||
class TestLogAdapter < Test::Unit::TestCase
|
||||
class LoggerDouble
|
||||
attr_accessor :level
|
||||
|
||||
def debug(*); end
|
||||
def info(*); end
|
||||
def warn(*); end
|
||||
def error(*); end
|
||||
end
|
||||
|
||||
context "#log_level=" do
|
||||
@@ -56,4 +61,20 @@ class TestLogAdapter < Test::Unit::TestCase
|
||||
assert_raise(SystemExit) { logger.abort_with('topic', 'log message') }
|
||||
end
|
||||
end
|
||||
|
||||
context "#messages" do
|
||||
should "return an array" do
|
||||
assert_equal [], Jekyll::LogAdapter.new(LoggerDouble.new).messages
|
||||
end
|
||||
|
||||
should "store each log value in the array" do
|
||||
logger = Jekyll::LogAdapter.new(LoggerDouble.new)
|
||||
values = %w{one two three four}
|
||||
logger.debug(values[0])
|
||||
logger.info(values[1])
|
||||
logger.warn(values[2])
|
||||
logger.error(values[3])
|
||||
assert_equal values.map { |value| "#{value} ".rjust(20) }, logger.messages
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
140
test/test_metadata.rb
Normal file
140
test/test_metadata.rb
Normal file
@@ -0,0 +1,140 @@
|
||||
require 'helper'
|
||||
|
||||
class TestMetadata < Test::Unit::TestCase
|
||||
context "The site metadata" do
|
||||
setup do
|
||||
FileUtils.rm_rf(source_dir(".jekyll-metadata"))
|
||||
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
|
||||
@site.process
|
||||
@path = @site.in_source_dir(@site.pages.first.path)
|
||||
@metadata = @site.metadata
|
||||
end
|
||||
|
||||
should "store modification times" do
|
||||
assert_equal File.mtime(@path), @metadata.metadata[@path]["mtime"]
|
||||
end
|
||||
|
||||
should "cache processed entries" do
|
||||
assert @metadata.cache[@path]
|
||||
end
|
||||
|
||||
should "write to the metadata file" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
@metadata.write
|
||||
assert File.file?(source_dir(".jekyll-metadata"))
|
||||
end
|
||||
|
||||
should "read from the metadata file" do
|
||||
@metadata = Metadata.new(@site)
|
||||
assert_equal File.mtime(@path), @metadata.metadata[@path]["mtime"]
|
||||
end
|
||||
|
||||
# Methods
|
||||
|
||||
should "be able to add a path to the metadata" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
assert_equal File.mtime(@path), @metadata.metadata[@path]["mtime"]
|
||||
assert_equal [], @metadata.metadata[@path]["deps"]
|
||||
assert @metadata.cache[@path]
|
||||
end
|
||||
|
||||
should "return true on nonexistent path" do
|
||||
@metadata.clear
|
||||
assert @metadata.add("/bogus/path.md")
|
||||
assert @metadata.regenerate?("/bogus/path.md")
|
||||
end
|
||||
|
||||
should "be able to force a path to regenerate" do
|
||||
@metadata.clear
|
||||
@metadata.force(@path)
|
||||
assert @metadata.cache[@path]
|
||||
assert @metadata.regenerate?(@path)
|
||||
end
|
||||
|
||||
should "be able to clear metadata and cache" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
assert_equal 1, @metadata.metadata.length
|
||||
assert_equal 1, @metadata.cache.length
|
||||
@metadata.clear
|
||||
assert_equal 0, @metadata.metadata.length
|
||||
assert_equal 0, @metadata.cache.length
|
||||
end
|
||||
|
||||
should "not regenerate a path if it is not modified" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
@metadata.write
|
||||
@metadata = Metadata.new(@site)
|
||||
|
||||
assert !@metadata.regenerate?(@path)
|
||||
end
|
||||
|
||||
should "not regenerate if path in cache is false" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
@metadata.write
|
||||
@metadata = Metadata.new(@site)
|
||||
|
||||
assert !@metadata.regenerate?(@path)
|
||||
assert !@metadata.cache[@path]
|
||||
assert !@metadata.regenerate?(@path)
|
||||
end
|
||||
|
||||
should "regenerate if path in not in metadata" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
|
||||
assert @metadata.regenerate?(@path)
|
||||
end
|
||||
|
||||
should "regenerate if path in cache is true" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
|
||||
assert @metadata.regenerate?(@path)
|
||||
assert @metadata.cache[@path]
|
||||
assert @metadata.regenerate?(@path)
|
||||
end
|
||||
|
||||
should "regenerate if file is modified" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
@metadata.metadata[@path]["mtime"] = Time.at(0)
|
||||
@metadata.write
|
||||
@metadata = Metadata.new(@site)
|
||||
|
||||
assert_not_same File.mtime(@path), @metadata.metadata[@path]["mtime"]
|
||||
assert @metadata.regenerate?(@path)
|
||||
end
|
||||
|
||||
should "regenerate if dependency is modified" do
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
@metadata.write
|
||||
@metadata = Metadata.new(@site)
|
||||
|
||||
@metadata.add_dependency(@path, "new.dependency")
|
||||
assert_equal ["new.dependency"], @metadata.metadata[@path]["deps"]
|
||||
assert @metadata.regenerate?("new.dependency")
|
||||
assert @metadata.regenerate?(@path)
|
||||
end
|
||||
|
||||
should "regenerate everything if metadata is disabled" do
|
||||
@site.config["full_rebuild"] = true
|
||||
@metadata.clear
|
||||
@metadata.add(@path)
|
||||
@metadata.write
|
||||
@metadata = Metadata.new(@site)
|
||||
|
||||
assert @metadata.regenerate?(@path)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -16,11 +16,11 @@ class TestSass < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
should "register the SCSS converter" do
|
||||
assert !!@site.getConverterImpl(Jekyll::Converters::Scss), "SCSS converter implementation should exist."
|
||||
assert !!@site.find_converter_instance(Jekyll::Converters::Scss), "SCSS converter implementation should exist."
|
||||
end
|
||||
|
||||
should "register the Sass converter" do
|
||||
assert !!@site.getConverterImpl(Jekyll::Converters::Sass), "Sass converter implementation should exist."
|
||||
assert !!@site.find_converter_instance(Jekyll::Converters::Sass), "Sass converter implementation should exist."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -99,6 +99,7 @@ class TestSite < Test::Unit::TestCase
|
||||
should "write only modified static files" do
|
||||
clear_dest
|
||||
StaticFile.reset_cache
|
||||
@site.metadata.clear
|
||||
|
||||
@site.process
|
||||
some_static_file = @site.static_files[0].path
|
||||
@@ -128,6 +129,7 @@ class TestSite < Test::Unit::TestCase
|
||||
should "write static files if not modified but missing in destination" do
|
||||
clear_dest
|
||||
StaticFile.reset_cache
|
||||
@site.metadata.clear
|
||||
|
||||
@site.process
|
||||
some_static_file = @site.static_files[0].path
|
||||
@@ -241,6 +243,7 @@ class TestSite < Test::Unit::TestCase
|
||||
context 'with orphaned files in destination' do
|
||||
setup do
|
||||
clear_dest
|
||||
@site.metadata.clear
|
||||
@site.process
|
||||
# generate some orphaned files:
|
||||
# single file
|
||||
@@ -328,7 +331,7 @@ class TestSite < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
bad_processor = "Custom::Markdown"
|
||||
s = Site.new(site_configuration('markdown' => bad_processor))
|
||||
s = Site.new(site_configuration('markdown' => bad_processor, 'full_rebuild' => true))
|
||||
assert_raise Jekyll::Errors::FatalException do
|
||||
s.process
|
||||
end
|
||||
@@ -348,7 +351,7 @@ class TestSite < Test::Unit::TestCase
|
||||
|
||||
should 'throw FatalException at process time' do
|
||||
bad_processor = 'not a processor name'
|
||||
s = Site.new(site_configuration('markdown' => bad_processor))
|
||||
s = Site.new(site_configuration('markdown' => bad_processor, 'full_rebuild' => true))
|
||||
assert_raise Jekyll::Errors::FatalException do
|
||||
s.process
|
||||
end
|
||||
@@ -418,7 +421,9 @@ class TestSite < Test::Unit::TestCase
|
||||
|
||||
context "manipulating the Jekyll environment" do
|
||||
setup do
|
||||
@site = Site.new(site_configuration)
|
||||
@site = Site.new(site_configuration({
|
||||
'full_rebuild' => true
|
||||
}))
|
||||
@site.process
|
||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||
end
|
||||
@@ -430,7 +435,9 @@ class TestSite < Test::Unit::TestCase
|
||||
context "in production" do
|
||||
setup do
|
||||
ENV["JEKYLL_ENV"] = "production"
|
||||
@site = Site.new(site_configuration)
|
||||
@site = Site.new(site_configuration({
|
||||
'full_rebuild' => true
|
||||
}))
|
||||
@site.process
|
||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||
end
|
||||
|
||||
@@ -43,6 +43,10 @@ CONTENT
|
||||
create_post(content, override)
|
||||
end
|
||||
|
||||
def highlight_block_with_opts(options_string)
|
||||
Jekyll::Tags::HighlightBlock.parse('highlight', options_string, ["test", "{% endhighlight %}", "\n"], {})
|
||||
end
|
||||
|
||||
context "language name" do
|
||||
should "match only the required set of chars" do
|
||||
r = Jekyll::Tags::HighlightBlock::SYNTAX
|
||||
@@ -59,37 +63,51 @@ CONTENT
|
||||
end
|
||||
end
|
||||
|
||||
context "initialized tag" do
|
||||
should "set the correct options" do
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby ', ["test", "{% endhighlight %}", "\n"])
|
||||
context "highlight tag in unsafe mode" do
|
||||
should "set the no options with just a language name" do
|
||||
tag = highlight_block_with_opts('ruby ')
|
||||
assert_equal({}, tag.instance_variable_get(:@options))
|
||||
end
|
||||
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos ', ["test", "{% endhighlight %}", "\n"])
|
||||
should "set the linenos option as 'inline' if no linenos value" do
|
||||
tag = highlight_block_with_opts('ruby linenos ')
|
||||
assert_equal({ :linenos => 'inline' }, tag.instance_variable_get(:@options))
|
||||
end
|
||||
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table ', ["test", "{% endhighlight %}", "\n"])
|
||||
should "set the linenos option to 'table' if the linenos key is given the table value" do
|
||||
tag = highlight_block_with_opts('ruby linenos=table ')
|
||||
assert_equal({ :linenos => 'table' }, tag.instance_variable_get(:@options))
|
||||
end
|
||||
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table nowrap', ["test", "{% endhighlight %}", "\n"])
|
||||
should "recognize nowrap option with linenos set" do
|
||||
tag = highlight_block_with_opts('ruby linenos=table nowrap ')
|
||||
assert_equal({ :linenos => 'table', :nowrap => true }, tag.instance_variable_get(:@options))
|
||||
end
|
||||
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl', ["test", "{% endhighlight %}", "\n"])
|
||||
should "recognize the cssclass option" do
|
||||
tag = highlight_block_with_opts('ruby linenos=table cssclass=hl ')
|
||||
assert_equal({ :cssclass => 'hl', :linenos => 'table' }, tag.instance_variable_get(:@options))
|
||||
end
|
||||
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl hl_linenos=3', ["test", "{% endhighlight %}", "\n"])
|
||||
should "recognize the hl_linenos option and its value" do
|
||||
tag = highlight_block_with_opts('ruby linenos=table cssclass=hl hl_linenos=3 ')
|
||||
assert_equal({ :cssclass => 'hl', :linenos => 'table', :hl_linenos => '3' }, tag.instance_variable_get(:@options))
|
||||
end
|
||||
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl hl_linenos="3 5 6"', ["test", "{% endhighlight %}", "\n"])
|
||||
should "recognize multiple values of hl_linenos" do
|
||||
tag = highlight_block_with_opts('ruby linenos=table cssclass=hl hl_linenos="3 5 6" ')
|
||||
assert_equal({ :cssclass => 'hl', :linenos => 'table', :hl_linenos => ['3', '5', '6'] }, tag.instance_variable_get(:@options))
|
||||
end
|
||||
|
||||
tag = Jekyll::Tags::HighlightBlock.new('highlight', 'Ruby ', ["test", "{% endhighlight %}", "\n"])
|
||||
should "treat language name as case insensitive" do
|
||||
tag = highlight_block_with_opts('Ruby ')
|
||||
assert_equal "ruby", tag.instance_variable_get(:@lang), "lexers should be case insensitive"
|
||||
end
|
||||
end
|
||||
|
||||
context "in safe mode" do
|
||||
setup do
|
||||
@tag = Jekyll::Tags::HighlightBlock.new('highlight', 'text ', ["test", "{% endhighlight %}", "\n"])
|
||||
@tag = highlight_block_with_opts('text ')
|
||||
end
|
||||
|
||||
should "allow linenos" do
|
||||
|
||||
@@ -120,6 +120,7 @@ class TestUtils < Test::Unit::TestCase
|
||||
|
||||
should "drop trailing punctuation" do
|
||||
assert_equal "so-what-is-jekyll-exactly", Utils.slugify("So what is Jekyll, exactly?")
|
||||
assert_equal "كيف-حالك", Utils.slugify("كيف حالك؟")
|
||||
end
|
||||
|
||||
should "ignore hyphens" do
|
||||
@@ -134,6 +135,10 @@ class TestUtils < Test::Unit::TestCase
|
||||
assert_equal "customizing-git-git-hooks", Utils.slugify("Customizing Git - Git Hooks")
|
||||
end
|
||||
|
||||
should "replace punctuation in any scripts by hyphens" do
|
||||
assert_equal "5時-6時-三-一四", Utils.slugify("5時〜6時 三・一四")
|
||||
end
|
||||
|
||||
should "not modify the original string" do
|
||||
title = "Quick-start guide"
|
||||
Utils.slugify(title)
|
||||
|
||||
Reference in New Issue
Block a user