You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if this is the right place to ask but I can't find any information about this.
Is it possible to have variables that span all the code blocks inside the same note?
(So I don't have to define the same variable more than once if I chose to make a new code block)
Something like this:
'''math
K = 200
S = 200
'''
here is a new code block
'''math
K + S => outputs: 400
'''
The text was updated successfully, but these errors were encountered:
Thanks, I can definitely understand the use-case and want this myself.
I think it might be tricky because all code blocks in a note would have to be re-calculated, but I will definitely look in to it when i get some of the near-term features out the door.
I'd thought about this when I was briefly contemplating having a go at a similar plugin. The main thing here is that e.g. numeralsMathBlockHandler should use one calculation context, and "accumulate" all new block content as it's repeatedly called. But on L227scope is created anew on every handler invocation. I spent a bit of time researching this, but don't have a solid solution yet. I'll writeup something for the forum (a query on Discord didn't produce much) and will report back here if I get anything useful.
My best idea so far would be to attach the state to the Document via an incantation such as this.doc[this.manifest.id]. Obviously, that state would need to be setup or torn down when the plugin was loaded/unloaded. I believe that would correctly scope the mathjs state to an instance of a note in one window. But I'm not finding a lifecycle hook that lets the plugin know when rendering starts, and therefore when to reset that state ala this.doc[this.manifest.id] = {}. (also, any approach should be wrapped in this.{get,set}MathState() or the like)
Some other things that come to mind to solve for this:
the ordering of rendering. You would want to ensure the document is rendered from top to bottom (and not in parallel) to ensure the state is repeatably and predictably propagated from block to block.
how to re-trigger rendering or calculation. For example if you set a variable at the top of a document you would, presumably, want to re-calculate and re-render any other blocks on the page to propagate new values
I don't know if this is the right place to ask but I can't find any information about this.
Is it possible to have variables that span all the code blocks inside the same note?
(So I don't have to define the same variable more than once if I chose to make a new code block)
Something like this:
'''math
K = 200
S = 200
'''
here is a new code block
'''math
K + S => outputs: 400
'''
The text was updated successfully, but these errors were encountered: