-
Notifications
You must be signed in to change notification settings - Fork 393
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
Add Markdown YAML header fields to notebook metadata #469
Comments
Alternatively, is there a way to specify this metadata in some other way than in the YAML header, so that it ends up stored in the notebook-wide |
Here's what that input markdown
This is the output notebook file that I get by running the command in OP: {
"cells": [
{
"cell_type": "raw",
"metadata": {
"lines_to_next_cell": 0
},
"source": [
"---\n",
"author: John Doe\n",
"title: Some serious math\n",
"---"
]
}
],
"metadata": {
"jupytext": {
"notebook_metadata_filter": "title,author"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 4
} And this is what I'm trying to achieve: {
"cells": [],
"metadata": {
"author": "John Doe",
"title": "Some serious math",
"jupytext": {
"notebook_metadata_filter": "title,author"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 4
} |
Hello @dlukes , thanks for asking! You were very close to finding the solution...
As you notice, the notebook metadata is always under the With the PR #471 we can add an example of this in the tests, but maybe you would have found useful to have a mention of this in the documentation... Where do you think we should add this? Thanks |
It's not necessary, see mwouts/jupytext#469.
D'oh! So close :) On the other hand, if this information makes it into the docs, I hope it will have been worth it, I think it will be useful for other people who use Jupytext with Jupyter Book.
I searched the docs for 'metadata', so I looked here (FYI, that section has a broken link to here which should probably point here instead?) and here. However, I think it would be most natural to put it in the Jupytext Markdown format description. There's already an example YAML block there, so add the custom metadata to that and one or two sentences commenting on it in the main text? And thank you for Jupytext as well as for responding so quickly! |
I have added a quick note about custom notebook metadata as you suggested it (and fixed the broken link). Thanks for your getting in touch! |
Thanks for addressing this so quickly! |
I would like to add custom fields to the Markdown YAML header (
title:
andauthor:
) and have them end up in the notebook's"metadata":
field upon conversion from Markdown to.ipynb
, instead of being copied as literal YAML into a raw cell at the beginning of the notebook. Is there a way to achieve that?I tried the following but it doesn't seem to work:
jupytext --to notebook test.md --update-metadata '{"jupytext": {"notebook_metadata_filter":"title,author"}}'
The
title:
andauthor:
YAML fields stay in the raw cell, and the notebook's"metadata":
field contains just literally what I passed to the--update-metadata
option, i.e.{"jupytext": {"notebook_metadata_filter":"title,author"}}
.The text was updated successfully, but these errors were encountered: