Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post can't handle metadata dict with 'content' key #113

Closed
razvanvilceanu opened this issue Jan 18, 2024 · 1 comment
Closed

Post can't handle metadata dict with 'content' key #113

razvanvilceanu opened this issue Jan 18, 2024 · 1 comment

Comments

@razvanvilceanu
Copy link

Hi,

I am using frontmatter in a python script to convert MD files to XML and I found this issue where I have an MD file having a field called 'content' for which, creating a Post instance doesn't work, returning the following exception:

  File "C:\work\projects\xxx\venv\Lib\site-packages\frontmatter\__init__.py", line 168, in loads
    return Post(content, handler, **metadata)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Post.__init__() got multiple values for argument 'content'

An easy fix for this would be to add a condition to replace the name of the key in metadata, if a content key is already existing:

        if 'content' in metadata.keys():
            metadata['metadata_content'] = metadata.pop('content')

In my case, I added it in the parse function, line 85.

Can this be implemented in the following release of the package?

@eyeseast
Copy link
Owner

Duplicate of #96

@eyeseast eyeseast marked this as a duplicate of #96 Jan 18, 2024
@eyeseast eyeseast closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants