bensomething / notion-formula-2.0-converter

Notion Formula 1.0 -> 2.0 converter!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

notion-formula-2.0-converter

https://wustep.github.io/notion-formula-2.0-converter/

2023-09-11 at 22 04 35@2x

About

On September 7, 2023, Notion released Formulas 2.0, which included a new editor and new language syntax changes. With the new language syntax changes, all pre-existing formulas were migrated automatically to preserve the same outputs.

However, you might still have formulas on older reference materials that aren't migrated. This tool can be used to best effort convert Notion formulas from 1.0 to 2.0.

These converted formulas will likely be more verbose and less powerful than new formula 2.0s written using the new language and functions! It's recommended that you learn the 2.0 language and rewrite formulas using the new functionality if you have the chance :).

This is NOT necessarily the same algorithm as the Notion converter, so results may be slightly different. This isn't officially supported and is just a lil pet project!

Usage

  • Install: npm install
  • Run dev: npm run dev
  • Build: npm run build

Important conversion notes

  • We convert "add", "subtract", "multiply", "divide", "pow", "mod" to their operator equivalents to match the 2.0 converter, but technically this usage is actually valid in 2.0 anyways -- except in the case of using "add" for adding strings.
  • Both this and the official converter convert ternaries X ? Y : Z to if(X, Y, Z), even though ternaries are supported!
  • In Notion, you can't actually save an errorneous formula. But this converter does no typechecking and very little error checking, so it doesn't know if your formula is invalid. It makes some guesses, but isn't comprehensive. Therefore, invalid formulas may lead to incorrect results.

About

Notion Formula 1.0 -> 2.0 converter!

License:MIT License


Languages

Language:TypeScript 97.1%Language:CSS 1.8%Language:HTML 0.9%Language:JavaScript 0.2%