Skip to content

[upgrade] added functionality to handle Properties#51

Merged
mfarragher merged 3 commits into
mfarragher:dev_with_propertiesfrom
Veethahavya:properties-handling
Jun 6, 2026
Merged

[upgrade] added functionality to handle Properties#51
mfarragher merged 3 commits into
mfarragher:dev_with_propertiesfrom
Veethahavya:properties-handling

Conversation

@Veethahavya
Copy link
Copy Markdown

Solves:

Credits:

  • GHCP Agent; Sonnet 3.5

mfarragher and others added 3 commits July 8, 2025 20:35
    - functionality to handle [Properties](https://help.obsidian.md/properties)
- limitation:
    - links in properties are not being handled
Copy link
Copy Markdown
Author

@Veethahavya Veethahavya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also added:

  • a notebook to illustrate functionality

@JavierGOrdonnez
Copy link
Copy Markdown

@mfarragher would be great if this PR could go in (allowing support for frontmatter properties is even more important now with the release of Obsidian Bases)

@mfarragher mfarragher changed the base branch from main to dev June 6, 2026 11:26
@mfarragher mfarragher changed the base branch from dev to dev_with_properties June 6, 2026 13:17
Copy link
Copy Markdown
Owner

@mfarragher mfarragher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this into a branch called dev_with_properties to do further development.

Examples of tweaks I'll make:

  • .obsidian/types.json contains types like datetime. That could be used to make the parsing logic more robust and generalise better than it does currently.
  • I'll re-organise the files used for tests
  • Some of the original tests that check the vault object are failing (they need to account for the new rich.md file in this PR).

Comment thread obsidiantools/md_utils.py
Comment on lines +560 to +594
if isinstance(value, str):
if clean_key == 'date' and len(value) == 10 and value[4] == '-' and value[7] == '-':
try:
value = datetime.datetime.strptime(value, '%Y-%m-%d').date()
except ValueError:
print(f"Failed to parse date for key '{clean_key}' with value '{value}' in frontmatter of {filepath}")
elif clean_key == 'time' and len(value) == 19 and value[4] == '-' and value[7] == '-' and value[10] == 'T':
try:
value = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
except ValueError:
pass
elif clean_key == 'due' and len(value) == 10 and value[4] == '-' and value[7] == '-':
try:
value = datetime.datetime.strptime(value, '%Y-%m-%d').date()
except ValueError:
pass
elif value.startswith("[[") and value.endswith("]]"):
# Handle single wikilink as a string
value = _get_all_wikilinks_from_source_text(value, remove_aliases=True)[0]
elif isinstance(value, list):
# Handle list of strings, checking for wikilinks
new_list = []
for item in value:
if isinstance(item, str) and item.startswith("[[") and item.endswith("]]"):
# Extract the wikilink
new_list.extend(_get_all_wikilinks_from_source_text(item, remove_aliases=True))
else:
new_list.append(item)
value = new_list
if clean_key in ('date', 'due') and all(isinstance(item, str) and len(item) == 10 and item[4] == '-' and item[7] == '-' for item in value):
try: # Convert to date objects if they match the pattern
value = datetime.datetime.strptime(value, '%Y-%m-%d').date()
except ValueError:
pass
props[clean_key] = value
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parsing looks like it could be simplified

@mfarragher mfarragher merged commit 72e7316 into mfarragher:dev_with_properties Jun 6, 2026
This was referenced Jun 6, 2026
@mfarragher
Copy link
Copy Markdown
Owner

@Veethahavya I've reworked the logic so that it is all integrated in api.py and parses the date & datetime properties via the types.json config file.

However a few edge case tests aren't working now and I'm not sure why, but it might be quicker for you to debug?: issue #56
(possibly to do with aspects like how the overrides work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants