chhoumann / MetaEdit

MetaEdit for Obsidian
https://bagerbach.com
GNU General Public License v3.0
393 stars 15 forks source link

Squar Brackets #67

Open MicheleDeZen opened 2 years ago

MicheleDeZen commented 2 years ago

I don't know if this is an issue or just me not understanding it correctly :

I have a dataview inline field like "[number:: 3]" and in a javascript view i am trying to increment the value by 1

I am using this code :

if (tag_type == "inline") {
  let value = await getPropertyValue(tag_name, note.file.path);
  console.log(value)
  value = value + amount;
  console.log(value)
  await update(tag_name, value, note.file.path);
}

If the field is written without any bracket like "number:: 3" it works, if i have it written like "[number:: 3]" it doesn't.

I think it is related to how the graphical tool is displaying the values image It seams like is reading the opening bracket in the key and the closing in the value image

SciJoy commented 2 years ago

I have the same problem. If I have the inline dataview value in brackets or parentheses. Also, if the inline dataview field is in a callout, I get the quote symbol too.

obsdiain dataview issue with metaedit

caasion commented 2 years ago

This also applies to lists, headers, and probably other characters too. image

Editing the value also contains things outside of the square brackets: image

It would be great if this is fixed because it's great being able to use this plugin without directly going into the callouts or back to live-preview to edit the value.

j21w91 commented 1 year ago

Hey, any update on this? Currently facing this exact issue

LuthanV commented 1 year ago

Hey, the issue is probably related to the inline file parser and related to Issue #78. Currently the InlineFileParser only looks for '::' as the marker for dataview inline fields. However, dataview inline field can take two forms.

  1. without preceding and subsequent content as MyDataviewField:: Value, or
  2. within other content as [MyDataViewField:: Value] Note the differences are the brackets [ ... ]. This is where the issue occurs.

A fix for this would be to check for [ and ] within the parsed line containing a :: and limit the key and value parts accordingly (2nd form of dataview fields). However, if no brackets are found, it should be assumed that the 1st form is intended.

ZackBoe commented 1 year ago

Came across what seems to be this issue when tinkering with QuickAdd's example Movie script, which uses inline fields with lists of links:

category:: [[Movies]]
director:: [[Lana Wachowski]], [[Lilly Wachowski]]
genre:: [[Action]], [[Sci-Fi]]
cast:: [[Keanu Reeves]], [[Laurence Fishburne]], [[Carrie-Anne Moss]]

Unfortunately, MetaEdit's getPropertiesInFile returns

{ "key": "category", "content": "[[Movies", "type": 1 },
{ "key": "director", "content": "[[Lana Wachowski", "type": 1 },
{ "key": "genre", "content": "[[Action", "type": 1 },
{ "key": "cast", "content": "[[Keanu Reeves", "type": 1 },

Possibly related is #84