Update AbstractParameter.php (#959)

* Update AbstractParameter.php

Make lazy null conditionals explicit.
Try to handle LaTeX special chars gracefully.
Fixes #958

* Only escape the percentage sign, so that you can still use latex for units

* Only escape previously unescaped percentage signs

* simplify regex

* Render the percentage sign correctly in units in the frontend.

---------

Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
This commit is contained in:
d-buchmann 2025-07-06 00:20:29 +02:00 committed by GitHub
parent 00a74ed96a
commit 2226b72d1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 8 deletions

View file

@ -33,7 +33,10 @@ export default class extends Controller {
{
let value = "";
if (this.unitValue) {
value = "\\mathrm{" + this.inputTarget.value + "}";
//Escape percentage signs
value = this.inputTarget.value.replace(/%/g, '\\%');
value = "\\mathrm{" + value + "}";
} else {
value = this.inputTarget.value;
}