summaryrefslogtreecommitdiff
path: root/bin/entities.php
diff options
context:
space:
mode:
authorTechnosophos <[email protected]>2013-04-10 15:42:49 -0500
committerTechnosophos <[email protected]>2013-04-10 15:42:49 -0500
commitab9d8dbaf0469a1ab419f283e1e1e21fec1c1b74 (patch)
treec3a6c7d9e0b4eaed6c67c862323b20d256da4f13 /bin/entities.php
parenta9dc2ac5aafbab2025f5aef6a1427f813e20fbac (diff)
Entity reference generator.
Diffstat (limited to 'bin/entities.php')
-rw-r--r--bin/entities.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/entities.php b/bin/entities.php
new file mode 100644
index 0000000..ee8b7b6
--- /dev/null
+++ b/bin/entities.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Fetch the entities.json file and convert to PHP datastructure.
+ */
+
+// The URL to the official entities JSON file.
+$ENTITIES_URL = 'http://www.w3.org/TR/2012/CR-html5-20121217/entities.json';
+
+$payload = file_get_contents($ENTITIES_URL);
+$json = json_decode($payload);
+
+$table = array();
+foreach ($json as $name => $obj) {
+ $sname = substr($name, 1, -1);
+ $table[$sname] = $obj->characters;
+}
+
+print '<?php
+$entities = ';
+var_export($table);
+print ';';
+//print serialize($table);