diff --git a/scripts/patchElementInspector.php b/scripts/patchElementInspector.php index 58f02652c..b7d13da6a 100755 --- a/scripts/patchElementInspector.php +++ b/scripts/patchElementInspector.php @@ -81,7 +81,7 @@ function loadPage($url) $text = preg_replace('#\\s+#', ' ', $node->textContent); - if (!preg_match("#^An? ([a-z0-5]+) element.*?s end tag may be omitted if the \\1 element is immediately followed by a(?:n(other)?)? #", $text, $m)) + if (!preg_match("#^An? ([a-z0-5]+) element.*?s end tag may be omitted if the \\1 element is immediately followed by a(?:n(?:other)?)? #", $text, $m)) { continue; } @@ -102,10 +102,15 @@ function loadPage($url) } elseif (preg_match('#^([a-z]+) element or an? ([a-z]+) element$#', $text, $m) || preg_match('#^([a-z]+) or ([a-z]+) element$#', $text, $m) - || preg_match('#^([a-z]+) element, or if it is immediately followed by an? ([a-z]+) element$#', $text, $m)) + || preg_match('#^([a-z]+) element, (?:or )?if it is immediately followed by an? ([a-z]+) element$#', $text, $m) + || preg_match('#^([a-z]+) element, if it is immediately followed by an? ([a-z]+) element, (?:or )?if it is immediately followed by an? ([a-z]+) element$#', $text, $m)) { $closeParent[$m[1]][$elName] = 0; $closeParent[$m[2]][$elName] = 0; + if (isset($m[3])) + { + $closeParent[$m[3]][$elName] = 0; + } } elseif (preg_match('#^((?:\\w+,? )*or [a-z]+) element(?:, or if there is no more content in the parent element and the parent element is an HTML element that is not an? (?:\\w+, )*or \\w+ element, or an autonomous custom element)?$#', $text, $m)) { @@ -358,15 +363,13 @@ function getContentModel($dl, $elName) $model['allowChildElement']['h6'][''] = 1; $model['allowChildCategory']['script-supporting element'][''] = 1; } - elseif ($text === 'tr and script-supporting elements') + elseif (preg_match('(^((?:\\w+, )+|\\w+ )and script-supporting elements$)', $text, $m)) { - $model['allowChildElement']['tr'][''] = 1; - $model['allowChildCategory']['script-supporting element'][''] = 1; - } - elseif ($text === 'td, th, and script-supporting elements') - { - $model['allowChildElement']['td'][''] = 1; - $model['allowChildElement']['th'][''] = 1; + preg_match_all('(\\w+)', $m[1], $m); + foreach ($m[0] as $elName) + { + $model['allowChildElement'][$elName][''] = 1; + } $model['allowChildCategory']['script-supporting element'][''] = 1; } elseif ($text === 'flow content, but with no header, footer, sectioning content, or heading content descendants') @@ -383,11 +386,6 @@ function getContentModel($dl, $elName) $model['denyDescendantCategory']['labelable element'][''] = 1; $model['denyDescendantElement']['label'][''] = 1; } - elseif ($text === 'li and script-supporting elements') - { - $model['allowChildElement']['li'][''] = 1; - $model['allowChildCategory']['script-supporting element'][''] = 1; - } elseif ($text === 'groups each consisting of dt elements followed by dd elements, script-supporting elements' || $text === 'if the element is a child of a dl element: dt elements followed by dd elements, script-supporting elements') { @@ -410,17 +408,6 @@ function getContentModel($dl, $elName) $model['allowChildElement']['img'][''] = 1; $model['allowChildCategory']['script-supporting element'][''] = 1; } - elseif ($text === 'option, optgroup, and script-supporting elements') - { - $model['allowChildElement']['option'][''] = 1; - $model['allowChildElement']['optgroup'][''] = 1; - $model['allowChildCategory']['script-supporting element'][''] = 1; - } - elseif ($text === 'option and script-supporting elements') - { - $model['allowChildElement']['option'][''] = 1; - $model['allowChildCategory']['script-supporting element'][''] = 1; - } elseif ($text === 'flow content followed by one figcaption element') { $model['allowChildElement']['figcaption'][''] = 1; diff --git a/src/Configurator/Helpers/ElementInspector.php b/src/Configurator/Helpers/ElementInspector.php index 28b3f1191..b1fec8e4a 100644 --- a/src/Configurator/Helpers/ElementInspector.php +++ b/src/Configurator/Helpers/ElementInspector.php @@ -75,15 +75,15 @@ class ElementInspector 'col'=>['c'=>"\0\0\100",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], 'colgroup'=>['c'=>"\0\2",'ac'=>"\0\0\100",'ac22'=>'not(@span)','dd'=>"\0",'nt'=>1,'e'=>1,'e?'=>'@span','b'=>1], 'data'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], - 'datalist'=>['c'=>"\5",'ac'=>"\4\200\0\40",'dd'=>"\0"], - 'dd'=>['c'=>"\0\100\0\1",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['dd','dt']], + 'datalist'=>['c'=>"\5",'ac'=>"\4\0\1\40",'dd'=>"\0"], + 'dd'=>['c'=>"\0\200\0\1",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['dd','dt']], 'del'=>['c'=>"\7",'ac'=>"\0",'dd'=>"\0",'t'=>1], 'details'=>['c'=>"\13",'ac'=>"\1\0\0\10",'dd'=>"\0",'b'=>1,'cp'=>['p']], 'dfn'=>['c'=>"\7\0\0\0\20",'ac'=>"\4",'dd'=>"\0\0\0\0\20"], 'dialog'=>['c'=>"\1",'ac'=>"\1",'dd'=>"\0",'b'=>1], - 'div'=>['c'=>"\3\100",'ac'=>"\1\200\0\1",'ac0'=>'not(ancestor::dl)','dd'=>"\0",'b'=>1,'cp'=>['p']], - 'dl'=>['c'=>"\3",'c1'=>'dt and dd','ac'=>"\0\300",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], - 'dt'=>['c'=>"\0\100\0\1",'ac'=>"\1",'dd'=>"\100\4\4",'b'=>1,'cp'=>['dd','dt']], + 'div'=>['c'=>"\3\200",'ac'=>"\1\0\1\1",'ac0'=>'not(ancestor::dl)','dd'=>"\0",'b'=>1,'cp'=>['p']], + 'dl'=>['c'=>"\3",'c1'=>'dt and dd','ac'=>"\0\200\1",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], + 'dt'=>['c'=>"\0\200\0\1",'ac'=>"\1",'dd'=>"\100\4\4",'b'=>1,'cp'=>['dd','dt']], 'em'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0",'fe'=>1], 'embed'=>['c'=>"\57",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1], 'fieldset'=>['c'=>"\203",'ac'=>"\1\0\0\100",'dd'=>"\0",'b'=>1,'cp'=>['p']], @@ -99,8 +99,8 @@ class ElementInspector 'h6'=>['c'=>"\103\1",'ac'=>"\4",'dd'=>"\0",'b'=>1,'cp'=>['p']], 'head'=>['c'=>"\0\0\20",'ac'=>"\20",'dd'=>"\0",'nt'=>1,'b'=>1], 'header'=>['c'=>"\3\20\4",'ac'=>"\1",'dd'=>"\0\0\4",'b'=>1,'cp'=>['p']], - 'hgroup'=>['c'=>"\103",'ac'=>"\0\201",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], - 'hr'=>['c'=>"\1\40",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1,'b'=>1,'cp'=>['p']], + 'hgroup'=>['c'=>"\103",'ac'=>"\0\1\1",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], + 'hr'=>['c'=>"\1\140",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1,'b'=>1,'cp'=>['optgroup','option','p']], 'html'=>['c'=>"\0",'ac'=>"\0\0\20",'dd'=>"\0",'nt'=>1,'b'=>1], 'i'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0",'fe'=>1], 'iframe'=>['c'=>"\57",'ac'=>"\4",'dd'=>"\0"], @@ -108,28 +108,28 @@ class ElementInspector 'input'=>['c'=>"\217",'c3'=>'@type!="hidden"','c7'=>'@type!="hidden" or @type="hidden"','c1'=>'@type!="hidden"','ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1], 'ins'=>['c'=>"\7",'ac'=>"\0",'dd'=>"\0",'t'=>1], 'kbd'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], - 'label'=>['c'=>"\17\0\0\0\4",'ac'=>"\4",'dd'=>"\0\0\1\0\4"], + 'label'=>['c'=>"\17\0\0\0\4",'ac'=>"\4",'dd'=>"\0\0\2\0\4"], 'legend'=>['c'=>"\0\0\0\100",'ac'=>"\104",'dd'=>"\0",'b'=>1], 'li'=>['c'=>"\0\0\0\0\100",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['li']], 'link'=>['c'=>"\25",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1], 'main'=>['c'=>"\3",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['p']], 'map'=>['c'=>"\7",'ac'=>"\0",'dd'=>"\0",'t'=>1], 'mark'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], - 'menu'=>['c'=>"\3\40",'c1'=>'li','ac'=>"\0\240",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], - 'menuitem'=>['c'=>"\0\40",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'b'=>1], + 'menu'=>['c'=>"\3\100",'c1'=>'li','ac'=>"\0\100\1",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], + 'menuitem'=>['c'=>"\0\100",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'b'=>1], 'meta'=>['c'=>"\25",'c0'=>'@itemprop','c2'=>'@itemprop','ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1], - 'meter'=>['c'=>"\7\0\1\0\2",'ac'=>"\4",'dd'=>"\0\0\0\0\2"], + 'meter'=>['c'=>"\7\0\2\0\2",'ac'=>"\4",'dd'=>"\0\0\0\0\2"], 'nav'=>['c'=>"\3\4",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['p']], 'noscript'=>['c'=>"\25",'ac'=>"\0",'dd'=>"\0",'nt'=>1], 'object'=>['c'=>"\47\0\0\2",'ac'=>"\0",'dd'=>"\0",'t'=>1], - 'ol'=>['c'=>"\3",'c1'=>'li','ac'=>"\0\200\0\0\100",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], - 'optgroup'=>['c'=>"\0\0\2",'ac'=>"\0\200\0\40",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['optgroup','option']], - 'option'=>['c'=>"\0\0\2\40",'ac'=>"\0",'dd'=>"\0",'b'=>1,'cp'=>['option']], + 'ol'=>['c'=>"\3",'c1'=>'li','ac'=>"\0\0\1\0\100",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], + 'optgroup'=>['c'=>"\0\40",'ac'=>"\0\0\1\40",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['optgroup','option']], + 'option'=>['c'=>"\0\40\0\40",'ac'=>"\0",'dd'=>"\0",'b'=>1,'cp'=>['option']], 'output'=>['c'=>"\207",'ac'=>"\4",'dd'=>"\0"], 'p'=>['c'=>"\3\1",'ac'=>"\4",'dd'=>"\0",'b'=>1,'cp'=>['p']], - 'picture'=>['c'=>"\47",'ac'=>"\0\200\40",'dd'=>"\0",'nt'=>1], + 'picture'=>['c'=>"\47",'ac'=>"\0\0\41",'dd'=>"\0",'nt'=>1], 'pre'=>['c'=>"\3",'ac'=>"\4",'dd'=>"\0",'pre'=>1,'b'=>1,'cp'=>['p']], - 'progress'=>['c'=>"\7\0\1\4",'ac'=>"\4",'dd'=>"\0\0\0\4"], + 'progress'=>['c'=>"\7\0\2\4",'ac'=>"\4",'dd'=>"\0\0\0\4"], 'q'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], 'rb'=>['c'=>"\0\10",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'b'=>1], 'rp'=>['c'=>"\0\10",'ac'=>"\0",'dd'=>"\0",'to'=>1,'b'=>1,'cp'=>['rp','rt']], @@ -138,9 +138,10 @@ class ElementInspector 'ruby'=>['c'=>"\7",'ac'=>"\4\10",'dd'=>"\0"], 's'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0",'fe'=>1], 'samp'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], - 'script'=>['c'=>"\25\200",'ac'=>"\0",'dd'=>"\0",'to'=>1], + 'script'=>['c'=>"\25\0\1",'ac'=>"\0",'dd'=>"\0",'to'=>1], + 'search'=>['c'=>"\3",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['p']], 'section'=>['c'=>"\3\4",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['p']], - 'select'=>['c'=>"\217",'ac'=>"\0\200\2",'dd'=>"\0",'nt'=>1], + 'select'=>['c'=>"\217",'ac'=>"\0\40\1",'dd'=>"\0",'nt'=>1], 'slot'=>['c'=>"\5",'ac'=>"\0",'dd'=>"\0",'t'=>1], 'small'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0",'fe'=>1], 'source'=>['c'=>"\0\0\40\20",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], @@ -150,20 +151,20 @@ class ElementInspector 'sub'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], 'summary'=>['c'=>"\0\0\0\10",'ac'=>"\104",'dd'=>"\0",'b'=>1], 'sup'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], - 'table'=>['c'=>"\3\0\0\0\1",'ac'=>"\0\202",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], - 'tbody'=>['c'=>"\0\2",'ac'=>"\0\200\0\0\40",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['tbody','td','th','thead','tr']], + 'table'=>['c'=>"\3\0\0\0\1",'ac'=>"\0\2\1",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], + 'tbody'=>['c'=>"\0\2",'ac'=>"\0\0\1\0\40",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['tbody','td','th','thead','tr']], 'td'=>['c'=>"\0\0\200",'ac'=>"\1",'dd'=>"\0",'b'=>1,'cp'=>['td','th']], - 'template'=>['c'=>"\25\200\100",'ac'=>"\0",'dd'=>"\0",'nt'=>1], + 'template'=>['c'=>"\25\0\101",'ac'=>"\0",'dd'=>"\0",'nt'=>1], 'textarea'=>['c'=>"\217",'ac'=>"\0",'dd'=>"\0",'pre'=>1,'to'=>1], - 'tfoot'=>['c'=>"\0\2",'ac'=>"\0\200\0\0\40",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['tbody','td','th','thead','tr']], + 'tfoot'=>['c'=>"\0\2",'ac'=>"\0\0\1\0\40",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['tbody','td','th','thead','tr']], 'th'=>['c'=>"\0\0\200",'ac'=>"\1",'dd'=>"\100\4\4",'b'=>1,'cp'=>['td','th']], - 'thead'=>['c'=>"\0\2",'ac'=>"\0\200\0\0\40",'dd'=>"\0",'nt'=>1,'b'=>1], + 'thead'=>['c'=>"\0\2",'ac'=>"\0\0\1\0\40",'dd'=>"\0",'nt'=>1,'b'=>1], 'time'=>['c'=>"\7",'ac'=>"\4",'ac2'=>'@datetime','dd'=>"\0"], 'title'=>['c'=>"\20",'ac'=>"\0",'dd'=>"\0",'to'=>1,'b'=>1], - 'tr'=>['c'=>"\0\2\0\0\40",'ac'=>"\0\200\200",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['td','th','tr']], + 'tr'=>['c'=>"\0\2\0\0\40",'ac'=>"\0\0\201",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['td','th','tr']], 'track'=>['c'=>"\0\0\0\200",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], 'u'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0",'fe'=>1], - 'ul'=>['c'=>"\3",'c1'=>'li','ac'=>"\0\200\0\0\100",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], + 'ul'=>['c'=>"\3",'c1'=>'li','ac'=>"\0\0\1\0\100",'dd'=>"\0",'nt'=>1,'b'=>1,'cp'=>['p']], 'var'=>['c'=>"\7",'ac'=>"\4",'dd'=>"\0"], 'video'=>['c'=>"\57\0\10",'c3'=>'@controls','ac'=>"\0\0\0\220",'ac28'=>'not(@src)','dd'=>"\0\0\10",'t'=>1], 'wbr'=>['c'=>"\5",'ac'=>"\0",'dd'=>"\0",'nt'=>1,'e'=>1,'v'=>1]