Fix #4082: Allow users to use .htm and .xhtml (XHTML5.)
This commit is contained in:
parent
b01b089f69
commit
90865d5fc1
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue