Skip to content

Unable to parse Obsidian template with date placeholder field #21

Description

@pursvir

Trace:

Traceback (most recent call last):
  File "<python-input-0>", line 3, in <module>
    front_matter = Frontmatter.read_file("/home/user/test.md")
  File "/home/user/.local/lib/python3.14/site-packages/frontmatter/__init__.py", line 18, in read_file
    return cls.read(file_contents)
           ~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.14/site-packages/frontmatter/__init__.py", line 37, in read
    "attributes": yaml.load(fmatter, Loader=yaml.FullLoader),
                  ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.14/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
           ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/user/.local/lib/python3.14/site-packages/yaml/constructor.py", line 43, in get_single_data
    return self.construct_document(node)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/user/.local/lib/python3.14/site-packages/yaml/constructor.py", line 52, in construct_document
    for dummy in generator:
                 ^^^^^^^^^
  File "/home/user/.local/lib/python3.14/site-packages/yaml/constructor.py", line 404, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/home/user/.local/lib/python3.14/site-packages/yaml/constructor.py", line 210, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.14/site-packages/yaml/constructor.py", line 133, in construct_mapping
    raise ConstructorError("while constructing a mapping", node.start_mark,
            "found unhashable key", key_node.start_mark)
yaml.constructor.ConstructorError: while constructing a mapping
  in "<unicode string>", line 2, column 8:
    Added: {{date:YYYY-MM-DD}}
           ^
found unhashable key
  in "<unicode string>", line 2, column 9:
    Added: {{date:YYYY-MM-DD}}
            ^

Code:

from frontmatter import Frontmatter

front_matter = Frontmatter.read_file("/home/user/test.md")

File content:

---
Added: {{date:YYYY-MM-DD}}
---

Sample text here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions