Plugin: Math Mode

Introducing Math Mode for Joplin! This is a plugin that will allow for special code blocks in markdown that evaluate all math inside of them.

It's built on mathjs, meaning it can do everything that mathjs can do. From derivates, and symbolic manipulation of expressions, to unit conversion and matrix operations.

The current release is still in beta and only includes the bare minimum, you'll see in the project readme that I plan to add more soon. If you have any ideas that would fit within the scope of this plugin (or any bugs), feel free to let me know here or on the github issue tracker for the plugin.

Warning: This plugin is very new, and I don't know exactly what kind of interface is going to be most practical. What you see above is the current implementation but I might change it if necessary or if I think a different presentation makes more sense (results on the next line for example).

19 Likes

That's brilliant, I'll need to give that a try.

2 Likes

wow, this is totally awesome! thanks!!

1 Like

This is great! It reminds me of the powerful Mac calculator program called Calca.

I have mixed feelings about what comes after the Calculate symbol ("=>"). The result of "cost_per_person: 175" is a bit redundant, since the left side of the equal sign already tells you the variable name.

Perhaps the calculated answer might be just the answer "=> 175" rather than "=> cost_per_person: 175". I have mixed feelings because I can see a use case for putting the variable name before the answer. You might want to copy the result and paste it into another program. In that case, having the variable name preceding the answer might be better.

1 Like

@hplphotos

I'm similarly conflicted about it. I'm tempted to remove it, but as you've noted there are situations where it greatly enhances read-ability. I think for now I'll leave it as is, and we'll wait for the plugin to be used a bit more before making changes (too be honest, I haven't been using it for long so this might be something we grow to love). I might also make a toggle to get the best of both worlds.

1 Like

I can understand both approaches. If I were to use it and I will use it in the future, I would like to be able to use both.
A toggle is one option, but it will only allow to change the setting globally (in case it is implemented as a setting). Maybe there's also a way to do something like:

```math
verbose = off|no|0
```
1 Like

Very cool plug in.

Question,

If I want to show the result to the rendered page how can I do that? Also possibly suppress the formula side and only display the result.

Copy and Paste doesn't seem to allow me to select the result of the calculation either which might be an easy way to do it.

Thanks for the cool plug in

Sandy

Thanks!

If I want to show the result to the rendered page how can I do that?

It's not possible yet, but I plan on adding support for inserting the result into the text.

Also possibly suppress the formula side and only display the result

Also not possible, but I like the idea, and I'll be adding it to the roadmap. I think this fit's well with the above discussion around verbosity.

I plan on fixing copy and paste soon, i've seen examples of it working but haven't properly put the time in to get it working here.

1 Like

Great to hear! I think this is going to be a really useful plugin. Saves me from having to pop up a calculator :wink:

Again, Excellent work!

Sandy

V0.2.0

  • Adds support for in-block configuration (based on @tessus's idea) which can be used to set display options as well as notation.
    image
    image
  • Adds support for inline calculations
    image

The plugin is not yet available on the Joplin plugin repository, but I have published, so it should be available soon!

Enjoy!

4 Likes

This plugin reminds me of https://soulver.com/, very useful, thank you!

1 Like

This is cool. Are there any plans to integrate these so they can be used with mobile apps?

Perhaps plug-ins can be synced too?

I don't know if there are any plans to introduce the plugin system on mobile. I do know however that even if that does happen, it will be unlikely that this plugin gets ported to mobile, it relies heavily on integration with the desktop markdown editor and wouldn't work at all on mobile.

Very useful thanks! Am using it in one of my notes now.

1 Like

V0.3.1

In this example you can see that the total variable takes on the value of the sum of all the preceding lines.
A new syntax is also added which will allow users to explicitly signal that a line is meant to add to (or remove from the total variable

+= 2+2 // Will add 4 to the total variable
-= 2+4 // remove 6 from the total variable
total => -2

The total variable is reset to zero if there is a line break between math lines, or if a new block is started.

I've also started adding examples to the github page. If anyone using this plugin has a good example, please send it my way and I'll add it! (With credit of course)

The update is available now on the Joplin plugin repository!

1 Like

V0.4.0

  • Now supports currency conversion (rates updated daily)

  • Default settings can now be changed in the Tools -> Options -> Math Mode menu (Preferences on MacOS)

The update has been pushed, so should be available from within Joplin by tomorrow!

3 Likes

V0.5.0

  • Clicking on a math result will copy it to clipboard
    image

  • Add fixed formatting

  • Add range options for the auto formatting

  • Add option to disable currency fetching

The update is pushed and should be available soon.

2 Likes

V0.5.2

Just a small patch to catch up with some of the theme updates that have happened in the base app recently

  • Math blacks will now be monospace (like all code blocks in Joplin). I haven't added an option for this yet, but I will consider it if there is demand.
  • Fixed a bug causing the plugin to interfere with code backgrounds

As always, the update has been pushed and should be available shortly.

Yep, it did. Thanks.

1 Like

@CalebJohn
First of all, thanks for this useful plugin
Secondly, I doubt the way to get a result with only one decimal e.g., =7/12=0.583333
I have checked in math.js | an extensive math library for JavaScript and Node.js founding we should add ROUND or ROUNDUP expression but, trying in different way and it is not working.
Could you help me suggesting the exact expression to add in Joplin for getting the result with only one decimal using the Math Mode plugin?
Thanks