Properly handle titles with trailing punctuation

This commit is contained in:
Chris Frederick 2014-09-01 13:25:38 +09:00
parent 93f63df172
commit a5e51cfdbe
3 changed files with 19 additions and 4 deletions

View File

@ -53,7 +53,7 @@ module Jekyll
# sequence of spaces and non-alphanumeric characters replaced with a # sequence of spaces and non-alphanumeric characters replaced with a
# hyphen. # hyphen.
def slug(name) def slug(name)
name.downcase.gsub(/[\W\s]+/, '-') name.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
end end
# The extension name of the document. # The extension name of the document.

View File

@ -0,0 +1,15 @@
---
title: So what is Jekyll, exactly?
layout: slide
---
Jekyll is a simple, blog-aware, static site generator. It takes a template
directory containing raw text files in various formats, runs it through
[Markdown](http://daringfireball.net/projects/markdown/) (or
[Textile](http://redcloth.org/textile)) and
[Liquid](http://wiki.shopify.com/Liquid)
converters, and spits out a complete, ready-to-publish static website suitable
for serving with your favorite web server. Jekyll also happens to be the engine
behind [GitHub Pages](http://pages.github.com), which means you can use Jekyll
to host your projects page, blog, or website from GitHubs servers **for
free**.

View File

@ -213,18 +213,18 @@ class TestDocument < Test::Unit::TestCase
"collections" => { "collections" => {
"slides" => { "slides" => {
"output" => true, "output" => true,
"permalink" => "/slides/test/:title" "permalink" => "/slides/:title"
} }
}, },
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir "destination" => dest_dir
})) }))
@site.process @site.process
@document = @site.collections["slides"].docs[0] @document = @site.collections["slides"].docs[3]
end end
should "produce the right URL" do should "produce the right URL" do
assert_equal "/slides/test/example-slide", @document.url assert_equal "/slides/so-what-is-jekyll-exactly", @document.url
end end
end end