Adding support for alternate doctypes (see REFERENCE). Also added a NON_NATIVE flag to the rcov rake

task because I was getting a segmentation fault with the native.


git-svn-id: svn://hamptoncatlin.com/haml/branches/edge@101 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2006-10-27 20:36:34 +00:00
parent a99fd555c7
commit 47616c9c97
5 changed files with 46 additions and 1 deletions

View File

@ -256,6 +256,24 @@ is compiled to:
</body>
</html>
You can also specify the version and type of XHTML after the <tt>!!!</tt>.
XHTML 1.0 Strict, Transitional, and Frameset and XHTML 1.1 are supported.
The default version is 1.0 and the default type is Transitional. For example,
!!! 1.1
is compiled to:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
and
!!! Strict
is compiled to:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
==== /
The forward slash character, when placed at the beginning of a line, wraps all

View File

@ -74,6 +74,9 @@ unless not_loaded.include? 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
if ENV['NON_NATIVE']
t.rcov_opts << "--no-rcovrt"
end
t.verbose = true
end
end

View File

@ -202,7 +202,21 @@ module Haml
end
when DOCTYPE
if line[0...3] == '!!!'
push_text '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
version, type = line.scan(/!!![\s]*([0-9]\.[0-9])?[\s]*([a-zA-Z]*)/)[0]
type = type.downcase if type
if version == "1.1"
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
else
case type
when "strict"
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
when "frameset"
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
else
doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
end
end
push_text doctype
else
@latest_command = PLAIN_TEXT
push_text line.strip

View File

@ -1,3 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<!-- Short comment -->
<!--
This is a really long comment look how long it is it should be on a line of its own don't you think?

View File

@ -1,3 +1,8 @@
!!!
!!! 1.1
!!! 1.1 Strict
!!! Strict foo bar
!!! FRAMESET
/ Short comment
/ This is a really long comment look how long it is it should be on a line of its own don't you think?
/