Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance upgrades #3321

Merged
merged 3 commits into from
Jan 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions features/collections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Feature: Collections
"""
When I run jekyll build
Then the _site directory should exist
And I should see "Item count: 1" in "_site/index.html"
And I should see "Item count: 2" in "_site/index.html"

Scenario: Sort by title
Given I have an "index.html" page that contains "{% assign items = site.methods | sort: 'title' %}1. of {{ items.size }}: {{ items.first.output }}"
Expand All @@ -130,7 +130,7 @@ Feature: Collections
"""
When I run jekyll build
Then the _site directory should exist
And I should see "1. of 6: <p>Page without title.</p>" in "_site/index.html"
And I should see "1. of 7: <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 %}"
Expand Down
9 changes: 3 additions & 6 deletions lib/jekyll/converters/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ def third_party_processors
].map(&:to_sym)
end

def extname_matches_regexp
@extname_matches_regexp ||= Regexp.new(
'^\.(' + @config['markdown_ext'].gsub(',','|') +')$',
Regexp::IGNORECASE
)
def extname_list
@extname_list ||= @config['markdown_ext'].split(',').map { |e| ".#{e.downcase}" }
end

def matches(ext)
ext =~ extname_matches_regexp
extname_list.include? ext.downcase
end

def output_ext(ext)
Expand Down
15 changes: 10 additions & 5 deletions lib/jekyll/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ module Jekyll
module Utils
extend self

# Constants for use in #slugify
SLUGIFY_MODES = %w{raw default pretty}
SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
SLUGIFY_DEFAULT_REGEXP = Regexp.new('[^[:alnum:]]+').freeze
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze

# Merges a master hash with another hash, recursively.
#
# master_hash - the "parent" hash whose values will be overridden
Expand Down Expand Up @@ -129,19 +135,18 @@ def has_yaml_header?(file)
def slugify(string, mode=nil)
mode ||= 'default'
return nil if string.nil?
return string.downcase unless SLUGIFY_MODES.include?(mode)

# Replace each character sequence with a hyphen
re = case mode
when 'raw'
Regexp.new('\\s+')
SLUGIFY_RAW_REGEXP
when 'default'
Regexp.new('[^[:alnum:]]+')
SLUGIFY_DEFAULT_REGEXP
when 'pretty'
# "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL
# and is allowed in both extN and NTFS.
Regexp.new("[^a-zA-Z0-9._~!$&'()+,;=@]+")
else
return string.downcase
SLUGIFY_PRETTY_REGEXP
end

string.
Expand Down