platers / obsidian-linter

An Obsidian plugin that formats and styles your notes with a focus on configurability and extensibility.
https://platers.github.io/obsidian-linter/
MIT License
1.26k stars 83 forks source link

FR: Ignore yaml-title rule if key exists with a value #1133

Open dlleigh opened 3 months ago

dlleigh commented 3 months ago

Is Your Feature Request Related to a Problem? Please Describe.

I recently started creating all new notes with a timestamp filename and a descriptive title property. My older notes have a descriptive filename that includes a datestamp and have no title property. I would like to update all old notes to have a title property that matches the descriptive filename.

The yaml-title rule works well for creating the desired property on the old notes, however it also replaces the descriptive title on the new notes that already have this property.

Describe the Solution You'd Like

I would like the yaml-title rule to optionally ignore files which already have the "title" key with a value.

Please include an example where applicable:

With the ignore option set:

---
title: this is a title that should not change
---

expected outcome:

---
title: this is a title that should not change
---

With the ignore option not set:

---
title: this is a title that should be replaced
---

expected outcome:

---
title: replaced-based-on-mode
---

Describe Alternatives You've Considered

The option to ignore existing keys & values could be rule-specific or a high-level option could potentially apply to multiple rules. The rule-specific implementation seems much more straightforward.

dcgk commented 2 months ago

This is an excellent suggestion and I would also very much appreciate this kind of rule. My usecase is slightly different:

Proposed solution: It would be excellent if before running the 'Insert title into YAML' rule there could be a simple check: If the property 'title' is not empty, do nothing.

Thank you for the brilliant Linter plug-in!