pyrochlore / obsidian-tracker

A plugin tracks occurrences and numbers in your notes
MIT License
1.37k stars 229 forks source link

Can't use regex in searchTarget with searchType: frontmatter? #296

Open ghost opened 10 months ago

ghost commented 10 months ago

It seems that it's not possible to use a regex for searchTarget when using searchType: frontmatter?

If anyone knows how, I would really appreciate a pointer. If it's not possible, consider this a feature request.

Expected Behavior

I'm trying to use nested frontmatter like

habits:
    one: true
    two: false

that can be referenced as habits.one and habits.two. But because of this issue preventing that from working for me, I'm trying to use quasi nested frontmatter like

habits-one: true    
habits-two: false

that can be referenced with regular expression habits-.*. (The idea is to add up how many habits are true and display the sum in a bullet chart.)

But this isn't working for me.

Current Behavior

I just get an error: "no valid Y value"

Possible Solution

When using searchType: text, we can already use a regex for searchTarget. See here in the docs. I think adding support for the same thing when using searchType: frontmatter would make a lot of sense!

Steps to Reproduce (for bugs)

Just try using searchType: frontmatter and any regex for searchTarget.

sahilarora535 commented 9 months ago

+1, facing the exact same issue, the frontmatter and tracker don't work as expected.

Frontmatter:

---
habit.waterIntake: 2
---

Tracker (doesn't work):

searchType: tag
searchTarget: habit.waterIntake
line:
  title: Water Intake

if I change the tracker type to text, it works perfectly:

searchType: text
searchTarget: habit.waterIntake
line:
  title: Water Intake

Looks like an issue with parsing nested YAML.