1
0
Fork 0
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:
Nathan Weizenbaum 2009-12-18 13:30:28 -08:00
commit 94704f9918
3 changed files with 22 additions and 4 deletions

View file

@ -133,6 +133,10 @@ that surrounds the filtered text with `<style>` and CDATA tags.
* Multi-line ERB statements are now properly indented,
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)
* Abstract out references to `ActionView::TemplateError`,

View file

@ -177,13 +177,14 @@ module Haml
class ::Hpricot::DocType
# @see Haml::HTML::Node#to_haml
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
type, version, strictness = attrs.map { |a| a.downcase }
if type == "html"
version = "1.0"
strictness = "transitional"
version = ""
strictness = "strict" if strictness == ""
end
if version == "1.0" || version.empty?
@ -194,7 +195,7 @@ module Haml
strictness = nil
end
version = " #{version}" if version
version = " #{version.capitalize}" if version
strictness = " #{strictness.capitalize}" if strictness
"#{tabulate(tabs)}!!!#{version}#{strictness}\n"

View file

@ -8,6 +8,19 @@ class Html2HamlTest < Test::Unit::TestCase
assert_equal '', render('')
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
assert_equal '%span#foo.bar', render('<span id="foo" class="bar"> </span>')
end