Joplin editor plugin for making calculations in markdown tables. Inspired by an Emacs Org mode feature which allows to make TBLFM comments under the table and perform calculations.
IMPORTANT: This plugin is not a spreadsheet emulator and I'm not able to mimic whole spreadsheet functionality. If you need specific behaviours, please use your favourite spreadsheet package instead.
Big thanks to authors of two projects which are the calculation engine core:
To define a set of table formulas, you can add a special HTML comment below a given Markdown table (TBLFM is a tribute to an Emacs Org mode :) . Only the first comment directly under the table will be taken into account. You can use TBLFM or TABLE_FORMULAS strings to indicate formula list.
| Column A | Column B | Column C |
| :------- | :------- | :------- |
| 123 | 456 | 789 |
| 0 | 0 | 0 |
<!--TBLFM C2=A1+A2; C1=56*78/4 -->
The comment can span multiple lines and contain multiple formulas separated by a semicolon. Formulas are calculated in the following order: first row then all its columns fron the left to the right, second row ... etc. Table cells are described using spreadsheet notation, columns designated with letters like A,B,C .. Z (and even more AA, AB etc.) and rows with integers 1,2,3 ... You can also use range notation like A1:E23
. Moreover, hot-formula-parser
contains also a big set of predefined functions which can be used in formulas.
For list of the formula functions and their use, please look at: https://formulajs.info/functions/ (however, I didn't check all of them).
There is also a possibility to define formulas directly inside the cell. To do so, you need to insert a special comment inside the cell content with FM or FORMULA indicator.
| Column A | Column B | Column C |
| :------- | :------- | :--------------- |
| 123 | 456 | 789 |
| 0 | 0 | <!--FM A1+C1 --> |
WARNING! If you use both cases in the same table, inline cell formulas are overwritten by the formulas put into the list below the table!
The plugin registers markdownCalculate
command and adds it to the editor toolbar (the fa-square-root-alt
icon).
editor.setText
command, so you will be unable to undo changes.7/18/2011 7:45:00 AM
will be properly parsed as float 7
. To use them as strings, they have to be written in double quote "7/18/2011 7:45:00 AM"
.To build the plugin, simply run npm run dist
.