Closed theofbonin closed 1 year ago
Hey @chhoumann!
I made some changes and now it seems to be working for every case. I fixed some bugs that I found and made it work with some other cases that I had thought about.
I changed the regex in "parser.ts" to a new one that conforms to the review:
/[\[\(]?([^\n\r\(\[]*)::[ ]*([^\)\]\n\r]*)[\]\)]?/g
Instead of using \s*
, I used [ ]*
, because using \s*
would cause problems with properties that are declared without a value.
I had to create the "escapeSpecialCharacters" method because properties with special regex characters were causing problems when editing the value. For instance, **Bold Field**
was causing:
Uncaught (in promise) SyntaxError: Invalid regular expression: /**Bold Field**:{1,2}/
I changed the regexes with ${property.key}
to ${this.escapeSpecialCharacters(property.key)}
.
I also changed the regexes in "metaController.ts" to conform to the review.
Known issues:
When there is more than one of the same field on the same file, it appears many times on the Metaedit screen (you can see this on the second screenshot with the field mood
). This shouldn't be an issue because the "right" way to declare fields on dataview is using lists or arrays:
field1:: [value1, value2, value3]
field2::
- value1
- value2
- ...
Even though it does accept many of the same field, like:
field:: value1
field:: value2
field:: value3
This will be considered by dataview as field:: [value1, value2, value3]
. Another problem related to this same thing is that when you modify the value of a field, it changes all occurrences of it in the file.
This issue was already happening even without accepting [field:: value]
and (field:: value)
, so it is not really related. However, I could try to figure out a way to work with many of the same field in the same file if you think that would be necessary.
This is fantastic, @theofbonin! Everything looks great. Awesome job. You even fixed #54! Thank you for the PR! Tagging here to close: fix #54
I'd love to see issues where you document your findings on the known issues you mention. I think those should be fixed, but I agree that this PR isn't the place to do it. It's good to avoid bloating change requests with too many things at once.
:tada: This PR is included in version 1.8.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
Changes to also parse for "(field:: value)" and "[field:: value]", as opposed to only "field:: value".