array( 0xA9 ), * 'characters' => '©', * ); * * @see https://html.spec.whatwg.org/entities.json * * @var array. */ $entities = json_decode( file_get_contents( __DIR__ . '/entities.json' ), JSON_OBJECT_AS_ARRAY ); /** * Direct mapping from character reference name to UTF-8 string. * * Example: * * $character_references['©'] === '©'; * * @var array. */ $character_references = array(); foreach ( $entities as $reference => $metadata ) { $reference_without_ampersand_prefix = substr( $reference, 1 ); $character_references[ $reference_without_ampersand_prefix ] = $metadata['characters']; } $html5_map = WP_Token_Map::from_array( $character_references ); /** * Contains the new contents for the auto-generated module. * * Note that in this template, the `$` is escaped with `\$` so that it * comes through as a `$` in the output. Without escaping, PHP will look * for a variable of the given name to interpolate into the template. * * @var string */ $module_contents = <<precomputed_php_source_table()}; EOF; file_put_contents( __DIR__ . '/../../../../src/wp-includes/html-api/html5-named-character-references.php', $module_contents ); if ( posix_isatty( STDOUT ) ) { echo "\e[1;32mOK\e[0;90m: \e[mSuccessfully generated optimized lookup class.\n"; } else { echo "OK: Successfully generated optimized lookup class.\n"; }