Browse Source

Add task for retrieving the list of known elements

master
J. King 1 year ago
parent
commit
9a610d0225
  1. 32
      RoboFile.php
  2. 3
      composer.json
  3. 231
      composer.lock
  4. 12
      vendor-bin/phpunit/composer.lock
  5. 50
      vendor-bin/robo/composer.lock

32
RoboFile.php

@ -1,6 +1,7 @@
<?php
use Robo\Result;
use MensBeam\HTML\DOMParser;
const BASE = __DIR__.\DIRECTORY_SEPARATOR;
const BASE_TEST = BASE."tests".\DIRECTORY_SEPARATOR;
@ -9,6 +10,8 @@ define("IS_MAC", php_uname("s") === "Darwin");
define("IS_LINUX", !IS_WIN && !IS_MAC);
error_reporting(0);
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";
function norm(string $path): string {
$out = realpath($path);
if (!$out) {
@ -153,4 +156,33 @@ class RoboFile extends \Robo\Tasks {
$c->addTask($this->taskExec(BASE_TEST."parsetests")->arg(BASE_TEST."platform-tests")->rawArg(">")->arg(BASE_TEST."cases".DIRECTORY_SEPARATOR."std-sanitize.json"));
return $c->run();
}
public function constants(): Result {
$c = $this->collectionBuilder()->addCode(function() {
$elems = [];
// retrieve the single-page HTML specification (this is around 15MB in size)
$spec = file_get_contents("https://html.spec.whatwg.org/");
// parse it (this may take several seconds
if ($spec) {
$p = new DOMParser;
$document = $p->parseFromString($spec, "text/html;charset=utf-8");
// pick out element definitions from the specification
foreach ($document->getElementsByTagName("dfn") as $el) {
if ($el->getAttribute("data-dfn-type") === "element") {
$elems[] = trim($el->textContent);
}
}
}
// sort and filter the results for unqiueness
sort($elems);
$elems = array_unique($elems);
// output the list of elements as a PHP array
$elems = array_map(function($e) {
return "'$e' => true";
}, $elems);
$elems = implode(", ", $elems);
echo "protected const KNOWN_ELEMENTS_HTML = [".$elems."];\n";
});
return $c->run();
}
}

3
composer.json

@ -31,7 +31,8 @@
}
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3"
"bamarni/composer-bin-plugin": "^1.3",
"mensbeam/html-parser": "^1.3"
},
"config": {
"allow-plugins": {

231
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ca1817f63eaf25e350da3b69bae122a0",
"content-hash": "2a1fcce4abef9d281df651d5260de85d",
"packages": [],
"packages-dev": [
{
@ -63,6 +63,235 @@
"source": "https://github.com/bamarni/composer-bin-plugin/tree/1.8.2"
},
"time": "2022-10-31T08:38:03+00:00"
},
{
"name": "mensbeam/html-parser",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/mensbeam/HTML-Parser.git",
"reference": "d499fac607ae06311df54887ba45c120797c76ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mensbeam/HTML-Parser/zipball/d499fac607ae06311df54887ba45c120797c76ed",
"reference": "d499fac607ae06311df54887ba45c120797c76ed",
"shasum": ""
},
"require": {
"ext-dom": "*",
"mensbeam/intl": ">=0.9.1",
"mensbeam/mimesniff": ">=0.2.0",
"php": ">=7.1"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3"
},
"suggest": {
"ext-ctype": "Improved performance"
},
"type": "library",
"autoload": {
"files": [
"lib/Parser/ctype.php"
],
"psr-4": {
"MensBeam\\HTML\\": [
"lib/"
]
},
"classmap": [
"lib/Parser/Token.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Dustin Wilson",
"email": "dustin@dustinwilson.com",
"homepage": "https://dustinwilson.com/"
},
{
"name": "J. King",
"email": "jking@jkingweb.ca",
"homepage": "https://jkingweb.ca/"
}
],
"description": "Parser and serializer for modern HTML documents",
"keywords": [
"HTML5",
"WHATWG",
"dom",
"html",
"parser",
"parsing"
],
"support": {
"source": "https://github.com/mensbeam/HTML-Parser/tree/1.3.0"
},
"time": "2023-04-02T01:38:10+00:00"
},
{
"name": "mensbeam/intl",
"version": "0.9.2",
"source": {
"type": "git",
"url": "https://github.com/mensbeam/intl.git",
"reference": "88dbf8398ab69e71164ac073f9ec011be2baa4ae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mensbeam/intl/zipball/88dbf8398ab69e71164ac073f9ec011be2baa4ae",
"reference": "88dbf8398ab69e71164ac073f9ec011be2baa4ae",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"bamarni/composer-bin-plugin": "*",
"ext-intl": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"MensBeam\\Intl\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "J. King",
"email": "jking@jkingweb.ca",
"homepage": "https://jkingweb.ca/"
}
],
"description": "A set of dependency-free basic internationalization tools",
"keywords": [
"WHATWG",
"charset",
"encoding",
"internationalization",
"intl",
"unicode",
"utf-8",
"utf8"
],
"support": {
"issues": "https://github.com/mensbeam/intl/issues",
"source": "https://github.com/mensbeam/intl/tree/0.9.2"
},
"time": "2023-01-25T22:12:58+00:00"
},
{
"name": "mensbeam/mimesniff",
"version": "0.2.1",
"source": {
"type": "git",
"url": "https://github.com/mensbeam/mime.git",
"reference": "c19be2496ab1e27fbf9c3483c2a9faa2781796cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mensbeam/mime/zipball/c19be2496ab1e27fbf9c3483c2a9faa2781796cd",
"reference": "c19be2496ab1e27fbf9c3483c2a9faa2781796cd",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr/http-message": "^1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3",
"ext-intl": "*"
},
"type": "library",
"autoload": {
"psr-4": {
"MensBeam\\Mime\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "J. King",
"email": "jking@jkingweb.ca",
"homepage": "https://jkingweb.ca/"
}
],
"description": "An implementation of the WHATWG MIME Sniffing specification",
"keywords": [
"WHATWG",
"mime",
"mimesniff"
],
"support": {
"issues": "https://github.com/mensbeam/mime/issues",
"source": "https://github.com/mensbeam/mime/tree/0.2.1"
},
"time": "2021-03-07T03:58:00+00:00"
},
{
"name": "psr/http-message",
"version": "1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/1.1"
},
"time": "2023-04-04T09:50:52+00:00"
}
],
"aliases": [],

12
vendor-bin/phpunit/composer.lock

@ -622,16 +622,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.6.6",
"version": "9.6.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "b65d59a059d3004a040c16a82e07bbdf6cfdd115"
"reference": "c993f0d3b0489ffc42ee2fe0bd645af1538a63b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b65d59a059d3004a040c16a82e07bbdf6cfdd115",
"reference": "b65d59a059d3004a040c16a82e07bbdf6cfdd115",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c993f0d3b0489ffc42ee2fe0bd645af1538a63b2",
"reference": "c993f0d3b0489ffc42ee2fe0bd645af1538a63b2",
"shasum": ""
},
"require": {
@ -705,7 +705,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.6"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.7"
},
"funding": [
{
@ -721,7 +721,7 @@
"type": "tidelift"
}
],
"time": "2023-03-27T11:43:46+00:00"
"time": "2023-04-14T08:58:40+00:00"
},
{
"name": "sebastian/cli-parser",

50
vendor-bin/robo/composer.lock

@ -957,16 +957,16 @@
},
{
"name": "symfony/console",
"version": "v6.2.7",
"version": "v6.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45"
"reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/cbad09eb8925b6ad4fb721c7a179344dc4a19d45",
"reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45",
"url": "https://api.github.com/repos/symfony/console/zipball/3582d68a64a86ec25240aaa521ec8bc2342b369b",
"reference": "3582d68a64a86ec25240aaa521ec8bc2342b369b",
"shasum": ""
},
"require": {
@ -1028,12 +1028,12 @@
"homepage": "https://symfony.com",
"keywords": [
"cli",
"command line",
"command-line",
"console",
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v6.2.7"
"source": "https://github.com/symfony/console/tree/v6.2.8"
},
"funding": [
{
@ -1049,7 +1049,7 @@
"type": "tidelift"
}
],
"time": "2023-02-25T17:00:03+00:00"
"time": "2023-03-29T21:42:15+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -1120,16 +1120,16 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v6.2.7",
"version": "v6.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "404b307de426c1c488e5afad64403e5f145e82a5"
"reference": "04046f35fd7d72f9646e721fc2ecb8f9c67d3339"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/404b307de426c1c488e5afad64403e5f145e82a5",
"reference": "404b307de426c1c488e5afad64403e5f145e82a5",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/04046f35fd7d72f9646e721fc2ecb8f9c67d3339",
"reference": "04046f35fd7d72f9646e721fc2ecb8f9c67d3339",
"shasum": ""
},
"require": {
@ -1183,7 +1183,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v6.2.7"
"source": "https://github.com/symfony/event-dispatcher/tree/v6.2.8"
},
"funding": [
{
@ -1199,7 +1199,7 @@
"type": "tidelift"
}
],
"time": "2023-02-14T08:44:56+00:00"
"time": "2023-03-20T16:06:02+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
@ -1818,16 +1818,16 @@
},
{
"name": "symfony/process",
"version": "v6.2.7",
"version": "v6.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "680e8a2ea6b3f87aecc07a6a65a203ae573d1902"
"reference": "75ed64103df4f6615e15a7fe38b8111099f47416"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/680e8a2ea6b3f87aecc07a6a65a203ae573d1902",
"reference": "680e8a2ea6b3f87aecc07a6a65a203ae573d1902",
"url": "https://api.github.com/repos/symfony/process/zipball/75ed64103df4f6615e15a7fe38b8111099f47416",
"reference": "75ed64103df4f6615e15a7fe38b8111099f47416",
"shasum": ""
},
"require": {
@ -1859,7 +1859,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v6.2.7"
"source": "https://github.com/symfony/process/tree/v6.2.8"
},
"funding": [
{
@ -1875,7 +1875,7 @@
"type": "tidelift"
}
],
"time": "2023-02-24T10:42:00+00:00"
"time": "2023-03-09T16:20:02+00:00"
},
{
"name": "symfony/service-contracts",
@ -1964,16 +1964,16 @@
},
{
"name": "symfony/string",
"version": "v6.2.7",
"version": "v6.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "67b8c1eec78296b85dc1c7d9743830160218993d"
"reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/67b8c1eec78296b85dc1c7d9743830160218993d",
"reference": "67b8c1eec78296b85dc1c7d9743830160218993d",
"url": "https://api.github.com/repos/symfony/string/zipball/193e83bbd6617d6b2151c37fff10fa7168ebddef",
"reference": "193e83bbd6617d6b2151c37fff10fa7168ebddef",
"shasum": ""
},
"require": {
@ -2030,7 +2030,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.2.7"
"source": "https://github.com/symfony/string/tree/v6.2.8"
},
"funding": [
{
@ -2046,7 +2046,7 @@
"type": "tidelift"
}
],
"time": "2023-02-24T10:42:00+00:00"
"time": "2023-03-20T16:06:02+00:00"
},
{
"name": "symfony/yaml",

Loading…
Cancel
Save