Index: lib/cgi/html.rb
===================================================================
--- lib/cgi/html.rb (Revision 36203)
+++ lib/cgi/html.rb (Arbeitskopie)
@@ -920,7 +920,7 @@
# O O or - O
for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
- COLGROUP TR TH TD HEAD]
+ COLGROUP TR TH TD HEAD ]
methods += <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
@@ -1016,6 +1016,57 @@
end
end # Html4Fr
-end
+ # Mixin module for HTML version 5 generation methods.
+ module Html5 # :nodoc:
+
+ # The DOCTYPE declaration for this version of HTML
+ def doctype
+ %||
+ end
+
+ # Initialise the HTML generation methods for this version.
+ def element_init
+ extend TagMaker
+ methods = ""
+ # - -
+ for element in %w[ SECTION NAV ARTICLE ASIDE HGROUP
+ FOOTER FIGURE FIGCAPTION S TIME U MARK RUBY BDI IFRAME
+ VIDEO AUDIO CANVAS DATALIST OUTPUT PROGRESS METER DETAILS
+ SUMMARY MENU DIALOG I B SMALL EM STRONG DFN CODE SAMP KBD
+ VAR CITE ABBR SUB SUP SPAN BDO ADDRESS DIV MAP OBJECT
+ H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT
+ FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
+ TEXTAREA FORM A BLOCKQUOTE CAPTION ]
+ methods += <<-BEGIN + nn_element_def(element) + <<-END
+ def #{element.downcase}(attributes = {})
+ BEGIN
+ end
+ END
+ end
+
+ # - O EMPTY
+ for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META
+ COMMAND EMBED KEYGEN SOURCE TRACK WBR ]
+ methods += <<-BEGIN + nOE_element_def(element) + <<-END
+ def #{element.downcase}(attributes = {})
+ BEGIN
+ end
+ END
+ end
+
+ # O O or - O
+ for element in %w[ HTML HEAD BODY P DT DD LI OPTION THEAD TFOOT TBODY
+ OPTGROUP COLGROUP RT RP TR TH TD ]
+ methods += <<-BEGIN + nO_element_def(element) + <<-END
+ def #{element.downcase}(attributes = {})
+ BEGIN
+ end
+ END
+ end
+ eval(methods)
+ end
+
+ end # Html5
+end
Index: lib/cgi/core.rb
===================================================================
--- lib/cgi/core.rb (Revision 36203)
+++ lib/cgi/core.rb (Arbeitskopie)
@@ -770,6 +770,7 @@
# "html4":: HTML 4.0
# "html4Tr":: HTML 4.0 Transitional
# "html4Fr":: HTML 4.0 with Framesets
+ # "html5":: HTML 5
#
# block::
# If provided, the block is called when an invalid encoding is
@@ -830,6 +831,11 @@
extend Html4Fr
element_init()
extend HtmlExtension
+ when "html5"
+ require 'cgi/html'
+ extend Html5
+ element_init()
+ extend HtmlExtension
end
end
Index: test/cgi/test_cgi_core.rb
===================================================================
--- test/cgi/test_cgi_core.rb (Revision 36175)
+++ test/cgi/test_cgi_core.rb (Arbeitskopie)
@@ -353,6 +353,14 @@
cgi = CGI.new('html4Fr')
expected = ''
assert_equal(expected, cgi.doctype)
+ ## html5
+ cgi = CGI.new('html5')
+ expected = ''
+ assert_equal(expected, cgi.doctype)
+ # cgi.header not broken
+ expected = "Content-Type: text/html\r\n\r\n"
+ actual = cgi.header
+ assert_equal(expected, actual)
end