[9] [DFN[[RUBYB[HTML構文]@en[The HTML syntax]]]] は、 [[HTML]] の構文の一種で、最もよく使われているものです。 [[HTML構文]]は [[SGML]] 風の構文を持っていますが、 [[SGML]] の[[部分集合]]でも[[超集合]]でもなく、 互換性はありません。[[HTML構文]]の第5版は特に [DFN[[[HTML5]]]] と呼ばれています。 ;; [10] [[HTML構文]]に対して、 [[XML]] を構文として採用したものを [[XHTML構文]]と呼びます。 [[XHTML構文]]の第5版は特に [DFN[[[XHTML5]]]] と呼ばれています。 [[XHTML構文]]は実際にはほとんど使われていません。 [11] [[HTML5]] (構文) や [[XHTML5]] は、どちらも [[HTML5]] 仕様書で定義されています (紛らわしいですね)。 [12] また、 [[DOM]] における [CODE(DOMi)@en[[[Document]]]] には [DFN[[RUBYB[[[HTML文書]]]@en[HTML document]]]]と[[XML文書]]の2種類があります [SRC[[[HTML5]]]]。両者は、元々どちらの構文で書かれていたかとおおむね一致します。 ;; 「おおむね」なのは、 [[DOM]] 上の操作で作られた [CODE(DOMi)@en[[[Document]]]] も存在するからです。 ;; ただし、両者を特に区別せずに「[[HTML文書]]」ということもあります ([[HTML5]] 仕様書の章節名自体がそうなっています)。 * 仕様書 -[13] [[HTML5]] 仕様書 -- * 媒体型 [14] [[HTML文書]] ([[HTML構文]]で記述された[[文書]]) は、[[媒体型]] [CODE(MIME)@en[[[text/html]]]] として[[札付け]]しなければ[['''なりません''']] [SRC@en[[[HTML5]]]]。 [15] 逆に、[CODE(MIME)@en[[[text/html]]]] と[[札付け]]された[[文書]]は [[HTML構文]]として解釈されます [SRC[[[HTML5]]]]。 * HTML 構文における刺激的な概念 - [18] [[DOCTYPEスイッチ]] - [16] [[里親付け]] - [17] [[養子縁組代理店算法]] ([[AAA]]) - [40] [[多妻ノアの箱舟]] * その他の話題 - [34] [[HTMLのレンダリングの開始]] * 歴史 ** Web Forms 2.0 HTML 構文の構文解析 [1] [[Web Forms 2.0]] は従来の [[HTML]] と [[XHTML]] の両方の構文を認めています。 この章では、 [[HTML]] 構文の[[構文解析]]について扱います。 [2] 仕様書: - [[Web Forms 2.0]] -- [CSECTION@en[2.18. Handling unexpected elements and values]] [3] '''誤り処理''' [[Web Forms 2.0]] は、 [[SGML]] で規定されない曖昧な場合にどう[[構文解析]]するか正確には規定しません。 [[利用者エージェント]]の実装者は、 既存の製品を[[逆工学]]し、適当な動作を模倣[['''するべきです''']]。 [SRC@en[WF2 2.18]] [5] [[Web Forms 2.0]] は [[HTML 4]] の拡張として定義されており、 その [[HTML 4]] が [[SGML]] に基づいているので、 >>3 のように規定されているのだと思われます。 しかし、 [[Web Forms 2.0]] の [[HTML]] [[文書]]は一般に[[妥当]]な [[SGML]] [[文書]]ではありません ([[DTD]] がないので)。 誤っている[[文書]]は >>4 のように処理するとして、 誤っていない[[文書]]をどう[[構文解析]]するのがいいのかは [[Web Forms 2.0]] は (わざと) 曖昧にしています。 ** HTML5 仕様書による構文解析算法の明確化 [8] [CITE['''['''whatwg''']''' HTML5 Parsing spec first draft ready]] ([TIME[2008-04-02 11:17:11 +09:00]] 版) * メモ [6] [CITE@en[Tag Soup: How Mac IE 5 and Safari handle ]] ([[Henri Sivonen]] 著, [CODE[2005-07-28 02:07:37 +09:00]] 版) [7] [CITE[Bug 311366 – should make custom elements able to contain blocks (
)]] ([TIME[2007-09-17 12:38:22 +09:00]] 版) [19] [CITE[IRC logs: freenode / #whatwg / 20090813]] ([TIME[2009-10-10 21:27:36 +09:00]] 版) [20] [CITE[IRC logs: freenode / #whatwg / 20100324]] ([TIME[2010-04-03 01:03:00 +09:00]] 版) [21] [CITE[Notes on HTML5 Parser History — Anne’s Weblog]] ([TIME[2010-06-03 08:06:42 +09:00]] 版) [22] [CITE['''['''webkit-dev''']''' HTML5 tokenizer landing soon]] ([TIME[2010-06-22 06:33:13 +09:00]] 版) [23] [CITE[IRC logs: freenode / #whatwg / 20100727]] ([TIME[2010-08-11 00:06:17 +09:00]] 版) [24] [CITE[IRC logs: freenode / #whatwg / 20100805]] ([TIME[2010-08-12 23:43:53 +09:00]] 版) [25] [CITE[IRC logs: freenode / #whatwg / 20100913]] ( ([TIME[2010-09-26 22:31:37 +09:00]] 版)) [26] [CITE[IRC logs: freenode / #whatwg / 20100915]] ( ([TIME[2010-09-28 00:57:22 +09:00]] 版)) [27] [CITE@en[Web Applications 1.0 r5521 Parser foreign lands: Get rid of secondary insertion mode, always use 'in body', scope HTML in foreign lands so that we won't try to close elements cross-namespace (e.g.

won't imply a

that closes the

...; won't close all the SVG if the SVG is in a cell).Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10314]] ( ([TIME[2010-09-28 08:45:00 +09:00]] 版)) [28] [CITE@en[Web Applications 1.0 r5522 Parser foreign lands: Oops, I missed one of the ways that scoping happens.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10314]] ( ([TIME[2010-09-28 08:54:00 +09:00]] 版)) [29] [CITE@en[Web Applications 1.0 r5563 Revamp how the foreign lands are defined to make it easier to add the U+0000 handling. This checkin should have no normative effect. If there are any normative changes in this patch, that's a bug, pleasel let me know ASAP.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=9659]] ( ([TIME[2010-09-30 10:40:00 +09:00]] 版)) [30] [CITE@en[Web Applications 1.0 r5638 Add in some hard-coded limits for dealing with unclosed formatting elements to limit the explosive growth of the list of formatting elements in commonly-seen cases.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10802]] ( ([TIME[2010-10-16 07:56:00 +09:00]] 版)) [31] [CITE[Bug 10802 – Limit the number of identical items on the list of active formatting elements by removing previous duplicates when adding new items]] ( ([TIME[2010-10-16 08:37:29 +09:00]] 版)) [32] [CITE[Bug 10801 – Limit the number of iterations in the loops in the AAA]] ( ([TIME[2010-10-16 08:38:38 +09:00]] 版)) [33] [CITE[IRC logs: freenode / #whatwg / 20101021]] ( ([TIME[2010-10-29 23:31:18 +09:00]] 版)) [35] [CITE@en[Web Applications 1.0 r5920 Change how MathML and SVG are parsed in text/html: use a three-level tree constructor design instead of the two-level design we had before.]] ( ([TIME[2011-03-01 08:56:00 +09:00]] 版)) [36] [CITE[IRC logs: freenode / #whatwg / 20110203]] ( ([TIME[2011-03-19 11:46:31 +09:00]] 版)) [37] [CITE@en-US[htmlparser: Summary]] ( ([TIME[2011-03-19 16:38:17 +09:00]] 版)) [38] [CITE[IRC logs: freenode / #whatwg / 20110608]] ( ([TIME[2011-06-11 01:00:34 +09:00]] 版)) [39] [CITE[IRC logs: freenode / #whatwg / 20110724]] ( ([TIME[2011-08-06 17:45:59 +09:00]] 版)) [41] [CITE[''''''[''''''whatwg'''''']'''''' foo
and other parser questions]] ( ([TIME[2011-12-14 08:37:32 +09:00]] 版)) [42] [CITE@en[Web Applications 1.0 r6870 Try to fix the problem David Flanagan raised a while back with the foo
test case.]] ( ([TIME[2011-12-14 07:36:00 +09:00]] 版)) [43] [CITE[IRC logs: freenode / #whatwg / 20120107]] ( ([TIME[2012-01-08 00:12:25 +09:00]] 版)) [44] [CITE[''''''[''''''whatwg'''''']'''''' HTMLLinkElement.disabled and HTMLLinkElement.sheet behavior]] ( ([TIME[2012-01-28 11:20:09 +09:00]] 版)) [45] [CITE[''''''[''''''whatwg'''''']'''''' document.write("\r"): the spec doesn't say how to handle it.]] ( ([TIME[2012-02-14 08:40:30 +09:00]] 版)) [46] [CITE@en[Web Applications 1.0 r6991 Rejig the wording of the character encoding section to make it more precise and in particular to not make CR processing require look-ahead.]] ( ([TIME[2012-02-14 07:48:00 +09:00]] 版)) [47] [CITE[''''''[''''''whatwg'''''']'''''' A plea to Hixie to adopt

, and main element parsing behaviour]] ( ([TIME[2012-11-08 07:11:56 +09:00]] 版)) [48] ( ([TIME[2012-11-09 02:23:02 +09:00]] 版)) [49] ( ([TIME[2012-03-12 04:52:17 +09:00]] 版))