Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring math.js formatting #91

Closed
NoahAndrews opened this issue Dec 29, 2023 · 5 comments · Fixed by #99
Closed

Allow configuring math.js formatting #91

NoahAndrews opened this issue Dec 29, 2023 · 5 comments · Fixed by #99

Comments

@NoahAndrews
Copy link
Contributor

math.js has many options to configure the formatting of its output. Unfortunately, if you're using heynote and you're not happy with the default values, you have to add an explicit format() call everywhere that you want to override them, which is annoying and puts quotation marks around the result that you have to remove when pasting. It would be much better if we could configure the math.js formatting options in the heynote settings.

@heyman
Copy link
Owner

heyman commented Dec 29, 2023

I've now fixed it (#92) so that string results won't render with quotation marks:

image

What's the use case for changing the default? I'm hesitant to add settings/features that very few users would use.

@NoahAndrews
Copy link
Contributor Author

NoahAndrews commented Dec 29, 2023

Nice!

The default that got in my way was auto-switching to exponent notation. As a software engineer, I sometimes calculate big numbers that I want be able to paste directly into my code.

@heyman
Copy link
Owner

heyman commented Dec 29, 2023

I've managed to fix it so that one can override the default format function within a math block, like this:

_format = format
format(x) = _format(x, {notation:"exponential"})
...

It's working, but I'll have to tidy it up and write some tests before I commit it.

image

Edit:
In my current fix, I've changed it so that if format is defined within the block it'll be used for both the display and copy value. I don't know if it would make sense to have something like formatDisplay and formatCopy instead?

@NoahAndrews
Copy link
Contributor Author

That was fast, thanks!

@NoahAndrews
Copy link
Contributor Author

NoahAndrews commented Dec 31, 2023

Personally I prefer the behavior of copying exactly what's displayed, so what you have now is fine

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 a pull request may close this issue.

2 participants