Skip to content
Snippets Groups Projects
Commit 1aa2dc44 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Code tidy.

parent 370da0d2
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,6 @@ define('CLI_SCRIPT', true); ...@@ -27,7 +27,6 @@ define('CLI_SCRIPT', true);
require(__DIR__ . '/../../../../config.php'); require(__DIR__ . '/../../../../config.php');
require_once($CFG->libdir . '/clilib.php'); require_once($CFG->libdir . '/clilib.php');
$greek = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/greek.json'); $greek = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/greek.json');
$letters = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/letters.json'); $letters = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/letters.json');
$subscripts = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/subscripts.json'); $subscripts = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/subscripts.json');
...@@ -35,11 +34,9 @@ $superscripts = file_get_contents('https://raw.githubusercontent.com/numbas/unic ...@@ -35,11 +34,9 @@ $superscripts = file_get_contents('https://raw.githubusercontent.com/numbas/unic
$symbols = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/symbols.json'); $symbols = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/symbols.json');
if ($greek === false || $letters === false || $subscripts === false || $superscripts === false || $symbols === false) { if ($greek === false || $letters === false || $subscripts === false || $superscripts === false || $symbols === false) {
die('Problem fetching the data.'); die('Problem fetching the data.');
} }
$greek = json_decode($greek, true); $greek = json_decode($greek, true);
$letters = json_decode($letters, true); $letters = json_decode($letters, true);
$subscripts = json_decode($subscripts, true); $subscripts = json_decode($subscripts, true);
...@@ -53,10 +50,10 @@ foreach ($greek as $key => $value) { ...@@ -53,10 +50,10 @@ foreach ($greek as $key => $value) {
switch ($value[0]) { switch ($value[0]) {
case 'inifinity': case 'inifinity':
$commonsymbolconversion[$key] = 'inf'; $commonsymbolconversion[$key] = 'inf';
continue; break;
case 'emptyset': case 'emptyset':
$commonsymbolconversion[$key] = '{}'; $commonsymbolconversion[$key] = '{}';
continue; break;
} }
$commonsymbolconversion[$key] = $value[0]; $commonsymbolconversion[$key] = $value[0];
} }
...@@ -86,7 +83,6 @@ foreach ($letters as $key => $value) { ...@@ -86,7 +83,6 @@ foreach ($letters as $key => $value) {
} }
} }
// Map things that have intermediary steps. // Map things that have intermediary steps.
$changes = true; $changes = true;
while ($changes) { while ($changes) {
...@@ -100,12 +96,10 @@ while($changes) { ...@@ -100,12 +96,10 @@ while($changes) {
} }
} }
// Then look at specific symbols, ops and parenthesis. // Then look at specific symbols, ops and parenthesis.
$symbolconversion = []; $symbolconversion = [];
foreach ($symbols as $key => $value) { foreach ($symbols as $key => $value) {
// Only pick certain ones // Only pick certain ones.
switch($value[0]) { switch($value[0]) {
case '-': case '-':
case '+': case '+':
...@@ -124,10 +118,7 @@ foreach ($symbols as $key => $value) { ...@@ -124,10 +118,7 @@ foreach ($symbols as $key => $value) {
case '>': case '>':
case '<': case '<':
$symbolconversion[$key] = $value[0]; $symbolconversion[$key] = $value[0];
} }
} }
$superscriptsconversion = []; $superscriptsconversion = [];
...@@ -158,11 +149,8 @@ foreach ($subscripts as $key => $value) { ...@@ -158,11 +149,8 @@ foreach ($subscripts as $key => $value) {
} }
} }
file_put_contents('../unicode/symbols-stack.json', json_encode($symbolconversion, JSON_PRETTY_PRINT)); file_put_contents('../unicode/symbols-stack.json', json_encode($symbolconversion, JSON_PRETTY_PRINT));
file_put_contents('../unicode/superscript-stack.json', json_encode($superscriptsconversion, JSON_PRETTY_PRINT)); file_put_contents('../unicode/superscript-stack.json', json_encode($superscriptsconversion, JSON_PRETTY_PRINT));
file_put_contents('../unicode/subscript-stack.json', json_encode($subscriptsconversion, JSON_PRETTY_PRINT)); file_put_contents('../unicode/subscript-stack.json', json_encode($subscriptsconversion, JSON_PRETTY_PRINT));
file_put_contents('../unicode/letters-stack.json', json_encode($commonsymbolconversion, JSON_PRETTY_PRINT)); file_put_contents('../unicode/letters-stack.json', json_encode($commonsymbolconversion, JSON_PRETTY_PRINT));
...@@ -26,7 +26,7 @@ Check ...@@ -26,7 +26,7 @@ Check
* [development history](Development_history.md) and [development track](Development_track.md) `history/track`. * [development history](Development_history.md) and [development track](Development_track.md) `history/track`.
* Execute `php cli/answertests_docs.php` to update the static docs about answertests. * Execute `php cli/answertests_docs.php` to update the static docs about answertests.
* Execute `doc/maintenance.php` to search for broken links etc. * Execute `doc/maintenance.php` to search for broken links etc.
* Execite `cli/unicode_data_process.php` to update unicode mappings. * Execute `cli/unicode_data_process.php` to update unicode mappings.
* version.php * version.php
* check both the Moodle versions, and the required number. (https://docs.moodle.org/dev/Releases) * check both the Moodle versions, and the required number. (https://docs.moodle.org/dev/Releases)
* `MATURITY_STABLE`? * `MATURITY_STABLE`?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment