thymer docs
Documentation/Writing/Calculations

Calculations

Inline code can do arithmetic. Put an expression in backticks and end it with =, and Thymer shows the result right after it:

`12 * 3 =`          shows 36
`(4 + 5) / 2 =`     shows 4.50

Name a value and use it anywhere on the page:

`hours = 6`
`rate = 80`
`total = hours * rate`     shows 480
`total * 1.21 =`           shows 580.80

What an expression can contain

  • Numbers: 12, 12.5, .5, and negative numbers like -3.
  • Names: letters, digits and underscores, starting with a letter or an underscore, such as rate or q3_target.
  • The operators +, -, * and /, with the usual precedence: multiplication and division first.
  • Parentheses to group.

Whole numbers show as they are; anything else shows with two decimals.

How values are shared

A page is one calculation space: every name defined in inline code on the page is available to every expression on it, in any order. Change hours at the top and total further down updates. A transcluded section or a live query block keeps its own space.

A plain `hours = 6` shows no result, only defines the name. `total = hours * rate` defines a name and shows its value. An expression that ends with = only shows a value.

When nothing shows

If an expression refers to a name that is not defined, divides by zero, or two names depend on each other, the result is NaN. If a page has no definitions at all, Thymer shows nothing for an undefined name, so a stray `x + y =` in ordinary notes stays quiet. A typo like 5 + * 3 = shows nothing either.

Calculations work in the text of a page. To compute a property from a page’s other properties, use a Formula.