Plugin: Note Variables

I guess my thought about using notes for your variables was that it would solve the syncing problem across devices. I'm sure the plugin would have to be rewritten, but it's not clear to me how including a few words or including an entire note are really different things. If they were notes that would allow the full power of Joplin to be used on them, including searching.

2 Likes

Not totally rewritten, as I said in a previous post:

Literally:

await joplin.settings.registerSettings({
            'variables': {
                value: '{}',
                type: SettingItemType.String,
                section: 'noteVariablesSection',
                public: false,
                label: 'Variables'
            },

I could just "move" that part of the code to save the variables into a note.
I think it's a good idea for solving the sync problem. I'm thinking of saving all the variables into a single note.

1 Like

! is used in markdown for inline images.

I also like $ since it is used in bash for environmental variables. Don't know if that interferes with the math notation, however...

1 Like

You were right. I'm rewriting the whole plugin data architecture, but I believe it's worth it.
The struggle it to maintain consistency between the cloud, the note where the variables will be stored, the runtime object that contains the variables, an item on localstorage that also contains the variables that I'm using to comunicate the plugin with the markdownitplugin, and the markdownitplugin runtime object that contains the variables.

Edit:
And that is just for the "happy path", I have to consider corruptions on the note. The user could mess with the integrity of the note.

2 Likes

Another vote for $, if there's a way not to exclude valid usage (e.g. $100.00).

This is an amazing plugin, thank you!

My concern is, how will this information be backed up? Can the variable definitions be stored in a note, so that they survive the export process?

2 Likes

Yes, I'm finishing that feature and by the next version all the variables will be stored in a note.

There will also be an option to set a custom variable delimiter, which will have to be like a "fence", just like %this%, or $this$. The only problem there is enclosing the variables with "$" is that it is used to make the text somekind Italic like this:
IMG_20211101_195324

1 Like

Hi everyone! Version 1.0.0 is now out; it now saves all the variables on a local note, so you can add, edit or remove them directly from the note. It also adds the option to manually set the variable "fence" or delimiter, like %this% or !this! or papayathispapaya (whatever you want).

To install this new version you'll need to uninstall the previous development version you had installed (<1.0.0) and install the brand new 1.0.0 or greater directly searching for it on Joplin.

4 Likes

The syntax $this$ is used by many branches of extended Markdown syntax to represent an inline equations (to be rendered by KaTeX, like what Joplin did, or so). So avoid using it seems to be a better idea.

1 Like

This is fantastic!

1 Like

Hi everyone!
It's been a while since the last update of the plugin, and I've seen that more people are using it and requesting some tweaks.

I've been working on making a new version of the plugin more user-friendly and a bit different from what it is now. Right now this is how It's looking, please let me know what you think:

The "Variables Notes" must be generated manually, and the variables can be directly modified on a MD table

To use the variables in a note, one must first "import" them, allowing to use of multiple variable groups on a single note. Here I'm importing the "%Variables%" note and trying to import an unexisting "%MyNoteVariables%", which marks the import in red:

What is different from the current version:

  1. There is no need to use a "fence" around variables, like %MyVar% inside a note, as now you can define your variables exactly as how you would use them in your notes.
  2. There can be an illimited number of variables notes as long as they have different names
  3. The right panel is gone (It's more practical to edit directly the variables note, and it was ugly)
  4. The variables note is now in MD table format instead of JSON
  5. The Variables Notes must be imported on each note, allowing to work with local variables and multiple variable groups, which allows having separate workspaces
5 Likes

Nice! Looks like a fantastic updates and massively improves usability! :grin::ok_hand:

Also, maybe a good idea to add a note to the original post in the thread that that info is now out of date?

EDIT: Also the github readme is out of date, sorry to point out that your docs are behind, I know it's a pain to update them all :sweat_smile:

1 Like

Just published v2.0.0 of the plugin.
As mentioned previously, the plugin works a bit different from v1.0.0:

  1. There can be as many Variables Notes as you need.
  2. The variables are saved in MD table format.
  3. To use the variables in a note you must import the Variables Note(s) you want to use.

I updated the Readme with the new usage.

Please let me know of any bugs or suggestions.

4 Likes

Great plugin, thanks for developing it!
I wonder whether it would be possible to extend the plugin functionality by adding a possibility to use variables defined in the note (i.e. not in the variables note, but exactly in the note where I need them)?

Let me provide an example.
I am going to use Joplin for planning social posts, and created for each day a separate note with the following structure:

Image: 
Hashtags: 

## LinkedIn

## Facebook
 
## Twitter

As you could imagine, the Hashtags will be the same for each social network, and I would need to define at the beginning of the file something like LocalHashtags{#cool #beautiful #useful} and than just put LocalHashtags variable in several places where I need it.
The solution you already implemented (i.e. having separate Variable notes) does not fit this purpose because hashtags will be different for each post, and it would be a challenge to keep them ordered in a single file.

I would need to combine the local and global variables, for example for taking the post footer from the global variables note.

Please could you let me know whether the extension of your plugin to the availability of local variables only for the current note is possible?

Thanks in advance!

1 Like

Sorry, I'm not currently planning to extend the functionality of the plugin. But what you say is a good idea to keep in mind if I do make an update.

Brilliant plugin. In combination with the plugin TextColorize, can set the string with colors or background color... Define it once and reuse it everywhere, like a tag but with colors. Maybe can embed links too.

1 Like