heyman / heynote

A dedicated scratchpad for developers
https://heynote.com
Other
3.85k stars 194 forks source link

Is there a way to have a javascript function for format in math blocks? #201

Open hanoii opened 6 months ago

hanoii commented 6 months ago

I don't know or think this is possible, but thought of asking.

I wanted to format the numbers with some locale as they are currently currency and it's easier to follow.

I managed to do it with:

format(x) = x.toLocaleString('es-ar');

However, I am not super sure about to extent of javascript I could do with format. I tried complex functions, anonymous functions, arrows functions ,but none worked. It this this work only because it ends up being a valid math block function, but can I use a more complex format callback some how in the max block?

heyman commented 1 month ago

The syntax should be that of Math.js expressions:

https://mathjs.org/docs/expressions/ https://mathjs.org/docs/expressions/syntax.html