-
Notifications
You must be signed in to change notification settings - Fork 197
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
Access Markdown frontmatter with env.metadata #947
Comments
It could be that #860 is also experiencing the same behavior/bug as I am. |
I am seeing some weird behaviour with accessing the metadata in general (outside the described issue above).
So in my case I am doing This could potentially be reported as a second bug somewhere (probably not in myst-parser) however that will have to be handled separately. |
I have tested with updated dependencies, same results:
|
Heya, metadata is collected in a transform, after the full document is parsed: https://github.com/sphinx-doc/sphinx/blob/05cc39d9b2a64b09504c06bfc2299aad96c85ccd/sphinx/environment/collectors/metadata.py#L28 so no you should not be relying on you can already do this though with: ---
myst:
substitutions:
last_review_date: 1970-09-08
---
The last review date of _this_ file was on {{ last_review_date }} |
What version of
myst-parser
are you using?3.0.1
What version dependencies are you using?
What operating system are you using?
Linux
Describe the Bug
Accessing frontmatter to use as content in the current file fails because the metadata of the file itself is not present in the
env.metadata
dict.Expected Behavior
It should be possible to access
env.metadata
for current file asenv.metadata[env.docname]["key"]
, just as it is possible to accessenv.metadata["another-file"]["key"]
.sphinx-doc/sphinx#2043 suggests that the "file wide metadata" should be accessible in the
env.metadata
dict, and it is for all other files, but just not the metadata that is in the file at hand.To Reproduce
A working set up to showcase the behavior can be found in this Gist: https://gist.github.com/holmboe/51dd5231301e0e282fc86922a17362ca
However, for the sake of completeness, here is a short example Markdown file:
The text was updated successfully, but these errors were encountered: