You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need examples of using MathJS within a button definition #669
While I have referenced the Math View page, I think that there needs to be probably another page under the button pages that also explains and provides some examples of how mathjs works with meta-bind.
First with some experimenting I was able to get a View to use mathjs correctly. Somewhere I found a reference to using a math namespace for mathjs functions. Yes, the mathjs pages specifically use this namespace but I thought I found a reference that was Obsidian specific (possibly using the meta-bind plugin) that used math, Math or mathjs. I can not find the reference now. It may also have been an AI hallucination. In any event, I tried the following with error of the namespace not being defined in JavaScript.
So I would request that the View Math page be updated with a couple of examples that show calling mathjs functions so that others do not run into the same problems and get frustrated.
What really triggered this divergence of being productive was that I have a Button that I built a while back and thought it was working at that time. Now I get failures in the console. That Button is defined as follows:
I think it would be worth a couple mins of time to create a new page on how to access the mathjs functions in a Button context.
Also, I found a reference to creating a Button using the InlineJS action and experimented with this also, but I had the same problem of not being able to access the the mathjs namespace.
OK, but this probably adds a good amount of confusion as mathjs is a JavaScript module and it is used elsewhere in the meta-bind plugin. So one would assume that mathjs would also be available for a Button. Especially to those of us that are semi-fluent in JavaScript but don't work in the JavaScript ecosystem all the time. Maybe there are technical difficulties that don't allow Buttons to use the mathjs module. I unfortunately don't have time to dig into the TypeScript code to understand how it operates. I certainly think it might be a good addition.
Activity
mProjectsCode commentedon Jun 18, 2026
Sure, I can add some more examples for view fields in the future, but note that buttons use JavaScript and not the mathjs language. (This is documented here: https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/buttonactions/updatemetadata/)
hickey commentedon Jun 18, 2026
Thanks for the quick response!
OK, but this probably adds a good amount of confusion as
mathjsis a JavaScript module and it is used elsewhere in themeta-bindplugin. So one would assume thatmathjswould also be available for a Button. Especially to those of us that are semi-fluent in JavaScript but don't work in the JavaScript ecosystem all the time. Maybe there are technical difficulties that don't allow Buttons to use themathjsmodule. I unfortunately don't have time to dig into the TypeScript code to understand how it operates. I certainly think it might be a good addition.You may consider a statement or two on https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/buttons/ that clarifies the context in which the buttons run so that others don't make the same mistake that I have made.
Thanks.