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

Code tidy.

parent 3a0f6e20
No related branches found
No related tags found
No related merge requests found
......@@ -27,11 +27,12 @@ define('CLI_SCRIPT', true);
require(__DIR__ . '/../../../../config.php');
require_once($CFG->libdir . '/clilib.php');
$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');
$subscripts = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/subscripts.json');
$superscripts = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/superscripts.json');
$symbols = file_get_contents('https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/symbols.json');
$baseurl = 'https://raw.githubusercontent.com/numbas/unicode-math-normalization/main/final_data/';
$greek = file_get_contents($baseurl . 'greek.json');
$letters = file_get_contents($baseurl . 'letters.json');
$subscripts = file_get_contents($baseurl . 'subscripts.json');
$superscripts = file_get_contents($baseurl . 'superscripts.json');
$symbols = file_get_contents($baseurl . 'symbols.json');
if ($greek === false || $letters === false || $subscripts === false || $superscripts === false || $symbols === false) {
die('Problem fetching the data.');
......
......@@ -32,11 +32,9 @@ class stack_ast_filter_180_char_based_superscripts implements stack_cas_astfilte
self::$ssmap = json_decode(file_get_contents(__DIR__ . '/../../maximaparser/unicode/superscript-stack.json'), true);
}
$process = function($node) use (&$errors, &$answernotes) {
if ($node instanceof MP_Identifier && !(isset($node->position['invalid']) && $node->position['invalid'])) {
// Iterate over the name to detect when we move from
// normal to superscript.
// Iterate over the name to detect when we move from normal to superscript.
$norm = true;
// Split to chars.
$chars = preg_split('//u', $node->value, -1, PREG_SPLIT_NO_EMPTY);
......@@ -70,7 +68,7 @@ class stack_ast_filter_180_char_based_superscripts implements stack_cas_astfilte
// Now if we have segments we need to deal with them.
if (count($segments) > 1) {
// Parts between which we have insert stars.
// x²x²x²x -> x^2*x^2*x^2*x
// E.g. x²x²x²x -> x^2*x^2*x^2*x.
$parts = [];
while (count($segments) > 1) {
$base = new MP_Identifier(array_shift($segments));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment