mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Merge branch 'stable'
Conflicts: doc-src/HAML_CHANGELOG.md lib/haml/html.rb
This commit is contained in:
commit
94704f9918
3 changed files with 22 additions and 4 deletions
|
@ -133,6 +133,10 @@ that surrounds the filtered text with `<style>` and CDATA tags.
|
||||||
* Multi-line ERB statements are now properly indented,
|
* Multi-line ERB statements are now properly indented,
|
||||||
and those without any content are removed.
|
and those without any content are removed.
|
||||||
|
|
||||||
|
## 2.2.17 (Unreleased)
|
||||||
|
|
||||||
|
* Fix compilation of HTML5 doctypes when using `html2haml`.
|
||||||
|
|
||||||
## [2.2.16](http://github.com/nex3/haml/commit/2.2.16)
|
## [2.2.16](http://github.com/nex3/haml/commit/2.2.16)
|
||||||
|
|
||||||
* Abstract out references to `ActionView::TemplateError`,
|
* Abstract out references to `ActionView::TemplateError`,
|
||||||
|
|
|
@ -177,13 +177,14 @@ module Haml
|
||||||
class ::Hpricot::DocType
|
class ::Hpricot::DocType
|
||||||
# @see Haml::HTML::Node#to_haml
|
# @see Haml::HTML::Node#to_haml
|
||||||
def to_haml(tabs, options)
|
def to_haml(tabs, options)
|
||||||
attrs = public_id.scan(/DTD\s+([^\s]+)\s*([^\s]*)\s*([^\s]*)\s*\/\//)[0]
|
attrs = public_id.nil? ? ["", "", ""] :
|
||||||
|
public_id.scan(/DTD\s+([^\s]+)\s*([^\s]*)\s*([^\s]*)\s*\/\//)[0]
|
||||||
raise Haml::SyntaxError.new("Invalid doctype") if attrs == nil
|
raise Haml::SyntaxError.new("Invalid doctype") if attrs == nil
|
||||||
|
|
||||||
type, version, strictness = attrs.map { |a| a.downcase }
|
type, version, strictness = attrs.map { |a| a.downcase }
|
||||||
if type == "html"
|
if type == "html"
|
||||||
version = "1.0"
|
version = ""
|
||||||
strictness = "transitional"
|
strictness = "strict" if strictness == ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if version == "1.0" || version.empty?
|
if version == "1.0" || version.empty?
|
||||||
|
@ -194,7 +195,7 @@ module Haml
|
||||||
strictness = nil
|
strictness = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
version = " #{version}" if version
|
version = " #{version.capitalize}" if version
|
||||||
strictness = " #{strictness.capitalize}" if strictness
|
strictness = " #{strictness.capitalize}" if strictness
|
||||||
|
|
||||||
"#{tabulate(tabs)}!!!#{version}#{strictness}\n"
|
"#{tabulate(tabs)}!!!#{version}#{strictness}\n"
|
||||||
|
|
|
@ -8,6 +8,19 @@ class Html2HamlTest < Test::Unit::TestCase
|
||||||
assert_equal '', render('')
|
assert_equal '', render('')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_doctype
|
||||||
|
assert_equal '!!!', render("<!DOCTYPE html>")
|
||||||
|
assert_equal '!!! 1.1', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">')
|
||||||
|
assert_equal '!!! Strict', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
|
||||||
|
assert_equal '!!! Frameset', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">')
|
||||||
|
assert_equal '!!! Mobile 1.2', render('<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">')
|
||||||
|
assert_equal '!!! Basic 1.1', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">')
|
||||||
|
assert_equal '!!!', render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
|
||||||
|
assert_equal '!!! Strict', render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">')
|
||||||
|
assert_equal '!!! Frameset', render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">')
|
||||||
|
assert_equal '!!!', render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">')
|
||||||
|
end
|
||||||
|
|
||||||
def test_id_and_class_should_be_removed_from_hash
|
def test_id_and_class_should_be_removed_from_hash
|
||||||
assert_equal '%span#foo.bar', render('<span id="foo" class="bar"> </span>')
|
assert_equal '%span#foo.bar', render('<span id="foo" class="bar"> </span>')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue