Skip to content

Feature/unicode superscripts#1674

Merged
sangwinc merged 3 commits intomaths:iss1676from
Bjoern-Ge:feature/unicode-superscripts
Feb 9, 2026
Merged

Feature/unicode superscripts#1674
sangwinc merged 3 commits intomaths:iss1676from
Bjoern-Ge:feature/unicode-superscripts

Conversation

@Bjoern-Ge
Copy link
Contributor

Enable Unicode superscript input (², ³, ¹) for algebraic inputs.

Only supports ², ³, ¹ (2-byte UTF-8, they are present on a German keyboard)

Results:
x² => x^2
x³ => x^3
x²+x² => x^2+x^2
x²² => x^22

added tests in
tests/fixtures/test_strings.json

addresses: #1107 (comment)

@christianp
Copy link
Contributor

@sangwinc did you not implement the stuff from https://github.com/numbas/unicode-math-normalization ?

$filterstoapply[] = '101_no_floats';
}

// Filter 180 MUST run BEFORE Filter 150!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of filters is based purely on the numbers at the start of the filter name. 180 will never get executed before 150, so if one wants to do something before 150, that something needs to be named accordingly.

The array filterstoapply is not the execution order for them. It is just the set of filters that need to be included in the filter pipeline; the pipeline construction logic then sorts that set and initialises the filters with any options they might have, as well as checks any issues related to incompatible filters.

Interesting, though, that the filter existed but was not used in the actual logic. Only in the input fixtures tests? Guess someone got busy with something else, and this was forgotten?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, though, that the filter existed but was not used in the actual logic. Only in the input fixtures tests? Guess someone got busy with something else, and this was forgotten?

Indeed @aharjula that's certainly probably me! Sorry, we can look into this.

@sangwinc
Copy link
Member

sangwinc commented Feb 9, 2026

Thanks so much @Bjoern-Ge I really appreciate you sending a pull request. Renaming it's simple (and we should stick to our current pattern, so important).

// handle latter, also strings are safe already.
// Option C: Allow only the most common superscripts: ², ³, ¹
// These are 2-byte UTF-8 characters and work without UTF-8mb4 requirement.
$superscript = ['²' => '2', '³' => '3', '¹' => '1'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christianp and I started a collection of patterns like this here.

https://github.com/sangwinc/unicode-math-normalization

We should link into this, rather than hard-wiring lists into the code.

@sangwinc sangwinc changed the base branch from master to iss1676 February 9, 2026 10:06
@sangwinc sangwinc merged commit 60d7a99 into maths:iss1676 Feb 9, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants