Changes to accept every Dataview metadata format#92
Changes to accept every Dataview metadata format#92chhoumann merged 2 commits intochhoumann:masterfrom theofbonin:master
Conversation
Changes to also parse for "(field:: value)" and "[field:: value]", as opposed to only "field:: value".
There was a problem hiding this comment.
Hey @theofbonin!
Thanks for the PR!
I've been testing for a bit using the Dataview docs material on inline fields:
Basic Field:: Some random Value
**Bold Field**:: Nice!
I would rate this a [rating:: 9]! It was [mood:: acceptable].
- [ ] Send an mail to David about the deadline [due:: 2022-04-05].
This will not show the (longKeyIDontNeedWhenReading:: key).And zooming in on rating gives

Which does seem to provide unexpected results. I'd expect it to prompt me for just rating with a pre-filled value of 9, rather than splitting the line.
Regarding your regex in parseInlineFields: I'd use a * after the \s rather than ? so the second match group doesn't get spaces, in case there are more than one. E.g. [mood: acceptable] would ignore the many spaces.

It also seems to be the cause of the unexpected results I mentioned above. Using the following leads to normal results:
Using const regex = /[\[\(]?([^\n\r\(\[]*)::\s?([^\)\]\n\r]*)[\]\)]?/g;
The only thing I added was [\[\(]? before the first group (key) and [\]\)]? after the second group (value).
Result:

…o handle special characters in properties. Updated "parser.ts" regex to handle properties without values and newlines after `::`. Also added "escapeSpecialCharacters" method to handle special regex characters in properties, and updated regexes on "metaController.ts".
|
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: I had to create the "escapeSpecialCharacters" method because properties with special regex characters were causing problems when editing the value. For instance, I changed the regexes with I also changed the regexes in "metaController.ts" to conform to the review. Known issues: Even though it does accept many of the same field, like: This will be considered by dataview as This issue was already happening even without accepting |
|
This is fantastic, @theofbonin! Everything looks great. Awesome job. You even fixed #54! Thank you for the PR! 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. |
|
🎉 This PR is included in version 1.8.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |





Changes to also parse for "(field:: value)" and "[field:: value]",
as opposed to only "field:: value".