Fix #4082: Allow users to use .htm and .xhtml (XHTML5.)

This commit is contained in:
Jordon Bedwell 2015-11-18 15:58:26 -06:00
parent b01b089f69
commit 90865d5fc1
2 changed files with 32 additions and 3 deletions

View File

@ -16,6 +16,15 @@ module Jekyll
url
]
# A set of extensions that are considered HTML or HTML-like so we
# should not alter them, this includes .xhtml through XHTM5.
HTML_EXTENSIONS = %W(
.html
.xhtml
.htm
)
# Initialize a new Page.
#
# site - The Site object.
@ -135,8 +144,8 @@ module Jekyll
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index.html") if url.end_with?("/")
path << output_ext unless path.end_with?(output_ext)
path = File.join(path, "index") if url.end_with?("/")
path << output_ext unless path.end_with?(output_ext)
path
end
@ -147,7 +156,7 @@ module Jekyll
# Returns the Boolean of whether this Page is HTML or not.
def html?
output_ext == '.html'
HTML_EXTENSIONS.include?(output_ext)
end
# Returns the Boolean of whether this Page is an index file or not.

View File

@ -261,6 +261,26 @@ class TestPage < JekyllUnitTest
assert File.exist?(File.join(dest_dir, 'contacts', 'index.html'))
end
should "support .htm extension and respects that" do
page = setup_page('contacts.htm')
page.site.permalink_style = :pretty
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
assert File.exist?(File.join(dest_dir, 'contacts', 'index.htm'))
end
should "support .xhtml extension and respects that" do
page = setup_page('contacts.xhtml')
page.site.permalink_style = :pretty
do_render(page)
page.write(dest_dir)
assert File.directory?(dest_dir)
assert File.exist?(File.join(dest_dir, 'contacts', 'index.xhtml'))
end
should "write properly with extension different from html" do
page = setup_page("sitemap.xml")
page.site.permalink_style = :pretty