diff options
-rw-r--r-- | bin/entities.php | 22 |
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); |