Merge branch 'stable'
This commit is contained in:
commit
83ff56e195
|
@ -140,6 +140,9 @@ that surrounds the filtered text with `<style>` and CDATA tags.
|
|||
|
||||
* Don't crash when parsing an XHTML Strict doctype in `html2haml`.
|
||||
|
||||
* Support the HTML5 doctype in an XHTML document
|
||||
by using `!!! 5` as the doctype declaration.
|
||||
|
||||
## [2.2.13](http://github.com/nex3/haml/commit/2.2.13)
|
||||
|
||||
* Allow users to specify {file:HAML_REFERENCE.md#encoding_option `:encoding => "ascii-8bit"`}
|
||||
|
|
|
@ -664,40 +664,55 @@ is compiled to:
|
|||
</body>
|
||||
</html>
|
||||
|
||||
You can also specify the version and type of XHTML after the `!!!`.
|
||||
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:
|
||||
You can also specify the specific doctype after the `!!!`
|
||||
When the [`:format`](#format) is set to `:xhtml` (the default),
|
||||
the following doctypes are supported:
|
||||
|
||||
!!! 1.1
|
||||
`!!!`
|
||||
: XHTML 1.0 Transitional<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">`
|
||||
|
||||
is compiled to:
|
||||
`!!! Strict`
|
||||
: XHTML 1.0 Strict<br/>
|
||||
`<!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.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
`!!! Frameset`
|
||||
: XHTML 1.0 Frameset<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">`
|
||||
|
||||
and
|
||||
`!!! 5`
|
||||
: XHTML 5<br/>
|
||||
`<!DOCTYPE html>`<br/>
|
||||
|
||||
!!! Strict
|
||||
`!!! 1.1`
|
||||
: XHTML 1.1<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">`
|
||||
|
||||
is compiled to:
|
||||
`!!! Basic`
|
||||
: XHTML Basic 1.1<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> `
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
`!!! Mobile`
|
||||
: XHTML Mobile 1.2<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">`
|
||||
|
||||
while
|
||||
When the [`:format`](#format) option is set to `:html4`,
|
||||
the following doctypes are supported:
|
||||
|
||||
!!! Basic
|
||||
`!!!`
|
||||
: HTML 4.01 Transitional<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">`
|
||||
|
||||
is compiled to:
|
||||
`!!! Strict`
|
||||
: HTML 4.01 Strict<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">`
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
|
||||
`!!! Frameset`
|
||||
: HTML 4.01 Frameset<br/>
|
||||
`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">`
|
||||
|
||||
and
|
||||
|
||||
!!! Mobile
|
||||
|
||||
is compiled to:
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
|
||||
When the [`:format`](#format) option is set to `:html5`,
|
||||
`!!!` is always `<!DOCTYPE html>`.
|
||||
|
||||
If you're not using the UTF-8 character set for your document,
|
||||
you can specify which encoding should appear
|
||||
|
|
|
@ -82,7 +82,7 @@ module Haml
|
|||
MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
|
||||
|
||||
# The Regex that matches a Doctype command.
|
||||
DOCTYPE_REGEX = /(\d\.\d)?[\s]*([a-z]*)/i
|
||||
DOCTYPE_REGEX = /(\d(?:\.\d)?)?[\s]*([a-z]*)/i
|
||||
|
||||
# The Regex that matches a literal string or symbol value
|
||||
LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?![\\#]|\2).|\\.)*\2/
|
||||
|
@ -857,6 +857,8 @@ END
|
|||
if xhtml?
|
||||
if version == "1.1"
|
||||
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
|
||||
elsif version == "5"
|
||||
'<!DOCTYPE html>'
|
||||
else
|
||||
case type
|
||||
when "strict"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
|
||||
|
|
|
@ -734,6 +734,7 @@ HAML
|
|||
def test_doctypes
|
||||
assert_equal('<!DOCTYPE html>',
|
||||
render('!!!', :format => :html5).strip)
|
||||
assert_equal('<!DOCTYPE html>', render('!!! 5').strip)
|
||||
assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
||||
render('!!! strict').strip)
|
||||
assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
|
||||
|
|
Loading…
Reference in New Issue