Display Formulas Inline

Use case or problem

Formulas allow to display large amount of information, but they are limited to Bases.
That makes it hard to build complex ideas for them, as they are limited in such way.
While it is possible to embed bases, it is not flexible enough.

I will mark that what i am asking is ability to display properties inline, rather then inline properties.

Proposed solution

Ability to use inline embed for formulas.
It would be easer with something like Global Formulas.
But formulas do work as strings so that fine too.

Current workaround

There are some plugins to display propertys inline, but no way to display formula equalent without certain about of JS.

2 Likes

What is an example of how you would use this?

Lets say i have propery Rank, that is a number.

Using

html(
  "<span style='font-size:24px; color:" +
    if(Rank<=3, "#CD7F32",

        if(Rank<=6, "#C0C0C0",

            if(Rank<=9, "#FFD700",

                "#a570f5"
              )
            
          
        )
      
    ) +
  "'>" +
    if(Rank==Rank.floor(), 
      "✦".repeat((Rank-1) % 3 + 1) +
      "âś§".repeat(3 - ((Rank-1) % 3 + 1)),
      "âś§âś§âś§"
    ) +
  "</span>"
)

It can be displayed as ✦✧✧ (<span style="font-size: 24px; color:#a570f5">✦✧✧</span>)
instead.

And later in the note it can be refered in places related to the rank.
As well as used in a wiki style box or simular places. As i usually hide properties all together.

It can be also used to dynamicaly get stuff like character lifespan based on dates.

Some of it probably can be fixed by having a Fliped table view

But that is also not here.

I’d also love a feature like this. I’ve used bases to basically create a dynamic dnd character sheet. I’ve defined all my stats and abilities in the frontmatter and created loads of inline bases with just one line (filtering for file == this.file) where I use formulas to calculate various things (e.g.:spellsave: 8 + this.file.properties['proficiency'] + (this.file.properties[this.file.properties['spellcastingattribute'].lower()] / 2).floor() - 5).

I’m also using meta bind views to get values inside of text like `VIEW[{charisma} / 2 - 5]`.

If it was possible to use expressions from bases inline I would not need to use meta bind anymore. For the above example the base expression would be this.file.properties['charisma'] / 2 - 5 But I can’t get the value outside of an inline base.

I’d also like this feature. With this you can create something like report notes, like the following:

I'm working on 5 projects.

4 of them are live: [[proj a]], [[proj b]], [[proj d]], [[proj e]]

2 use framework xy: [[proj b]], [[proj c]]

3 have open tasks: [[proj a]], [[proj c]], [[proj d]]

It would require inline formulas to calculate all the numbers and project lists dynamically.

Similar to the idea of @volllly I’d also like to be able to create notes that calculate something based on some input values. Using a note for this is a lot simpler than creating a spreadsheet file or a shell script or something similar.

Another use-case would be to define fixed terms or names in a file and re-use them throughout multiple other notes. I think combined with other features this allows you to replace parts of a text dynamically and make something similar to form letters or text templates.

This entire idea is also similar to Jupyter Notebooks but code could also be inline instead of just in a block which makes it even more flexible in terms of placement. Even if I just have a hand full of ideas what to do with this I think this is one of those things where the community will come up with hundreds of other use-cases once it gets available to everyone.

1 Like