-
Notifications
You must be signed in to change notification settings - Fork 567
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
Use "title" instead of "name" for metadata to match the notebook format #703
Conversation
Changing this would effectively be breaking API, because separately developed exporters and templates can use the resources dictionary. |
There's a version of this that can be done… specifically the html and slides templates could have this change in the vein of #672… Though the logic needs to be richer to handle the case where the title is not set… as can be seen in that PR, e.g.,: nbconvert/nbconvert/templates/latex/base.tplx Lines 143 to 149 in 5c0279a
|
We could add some code to ensure compatibility to metadata containing "name" (e.g. copy it to "title")? Then we could match the notebook format. |
No… we shouldn't overwrite the current logic of As @takluyver pointed out, there is an implicit API that we should be hesitant to change, so anything that we can do that instead works entirely inside templates is going to be safer. This problem can be addressed in the templates, so let's go with that option. |
Re: the format, technically the name and the title are different kinds of things. We just have used the name as though it were the title in nbconvert… There is no guarantee that the title is present in a notebook, it's just an option and we shouldn't overwrite notebooks to have a title when they don't. Here's a model of why this would go wrong: Suppose someone ran nbconvert in-place while their notebook was named |
Ah, understood. I will look into the templates tomorrow. |
This is almost correct, but it's actually in the notebook metadata itself, not in the resources metadata. So, the call would be |
Also, even cleaner might be to set a variable to either of the values (using an That'd be cleaner for the other LaTeX version as well. |
Ah, I mixed up those two metadata dicts. Thanks! For your second recommendation you mean using |
Yes something like |
@m-rossi I thought we had implemented examples of that already in our templates and in searching, I'm seeing that we hadn't. Are you running into any issue implementing that logic? I'm happy to help out if you are — Jinja can be weird sometimes around logical constructs & I have some ideas if that does not work in a straightforward way. |
Sorry for the delay, I've just added the few lines. |
I think it’d be better to have it local to the block just to keep the logic local. But it’s not a big difference. I can either merge this or wait for you to make the change, which would you prefer? |
No problem, I've just moved the lines. |
Beautiful! Merging! Many thanks! |
The notebook format has a metadata field for the "title" of the notebook: https://github.com/jupyter/nbformat/blob/master/nbformat/v4/nbformat.v4.schema.json#L63
I think it should be used instead of the field "name".