arnog / mathlive

A web component for easy math input
https://cortexjs.io/mathlive
MIT License
1.26k stars 260 forks source link

& not working as expected in custom macros #2390

Open andrew-murdza opened 3 weeks ago

andrew-murdza commented 3 weeks ago

Html code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Change FontShape of MathField</title>
  <script defer src="https://unpkg.com/mathlive"></script>
</head>
<body>
<h1>MathField FontShape Example</h1>
<math-field id='mf'>\begin{aligned}\bu11\\\bu2\end{aligned}</math-field>
<script>
  customElements.whenDefined("math-field").then(() => {
    document.body.classList.add("ready");
    mf=document.getElementById('mf');
    mf.macros={...mf.macros,bu:'&\\bullet~~'}
  });
</script>
</body>
</html>

Description

When & is used inside of a macro, it is treated as the letter & and not the latex character &

Steps to Reproduce

Run the attached html code

Actual Behavior

The bullets are not lined up and there is a letter &

Expected Behavior

The bullets are lined up (because there are &'s an an aligned environment) and there is no "&" letter present in the output.

Environment

Windows Chrome