Merge pull request #4160 from jekyll/fix-html-htm-xhtml-pages
Merge pull request 4160
This commit is contained in:
commit
ac1b2b88d4
|
@ -16,6 +16,15 @@ module Jekyll
|
||||||
url
|
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.
|
# Initialize a new Page.
|
||||||
#
|
#
|
||||||
# site - The Site object.
|
# site - The Site object.
|
||||||
|
@ -135,7 +144,7 @@ module Jekyll
|
||||||
# Returns the destination file path String.
|
# Returns the destination file path String.
|
||||||
def destination(dest)
|
def destination(dest)
|
||||||
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
||||||
path = File.join(path, "index.html") if url.end_with?("/")
|
path = File.join(path, "index") if url.end_with?("/")
|
||||||
path << output_ext unless path.end_with?(output_ext)
|
path << output_ext unless path.end_with?(output_ext)
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
@ -147,7 +156,7 @@ module Jekyll
|
||||||
|
|
||||||
# Returns the Boolean of whether this Page is HTML or not.
|
# Returns the Boolean of whether this Page is HTML or not.
|
||||||
def html?
|
def html?
|
||||||
output_ext == '.html'
|
HTML_EXTENSIONS.include?(output_ext)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the Boolean of whether this Page is an index file or not.
|
# 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'))
|
assert File.exist?(File.join(dest_dir, 'contacts', 'index.html'))
|
||||||
end
|
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
|
should "write properly with extension different from html" do
|
||||||
page = setup_page("sitemap.xml")
|
page = setup_page("sitemap.xml")
|
||||||
page.site.permalink_style = :pretty
|
page.site.permalink_style = :pretty
|
||||||
|
|
Loading…
Reference in New Issue