typograph-editor-documentation
    Preparing search index...

    Function evaluate_arithmetic

    • The number a designer typed into a numeric field, sums included: 210/2, 10 + 3.5, (297 - 20) / 3, -4.

      These fields used to hand their text to window.eval(), which ran whatever was typed or pasted as script in the editor's page (TYP-1372). This reads only numbers, + - * /, parentheses and spaces. A comma counts as a decimal point, as a Dutch designer types it; eval read 1,5 as the comma operator, so as 5. Anything else, an empty field and a result that is not a finite number (a division by zero) give NaN: the caller then leaves the value as it was.

      Parameters

      • text: string

      Returns number