-
Notifications
You must be signed in to change notification settings - Fork 568
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 a toc for html and latex exporter #2178
base: main
Are you sure you want to change the base?
Add a toc for html and latex exporter #2178
Conversation
…markdown contents.
for more information, see https://pre-commit.ci
20a8394
to
16166f0
Compare
6bc676c
to
f7eb4c4
Compare
322c26c
to
6b3946a
Compare
…the items of the table of contents.
d16bad8
to
3fefaae
Compare
e7678a3
to
04011ea
Compare
2a3e213
to
5de2600
Compare
469368e
to
05f6f11
Compare
19fcd8c
to
5f26a5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! I don't have much to say, it looks good to me. I just have a tiny nitpicky comment about the CLI usage
e4cef00
to
cb90485
Compare
for more information, see https://pre-commit.ci
nbconvert/exporters/html.py
Outdated
if resources is None: | ||
resources = {} | ||
resources.update( | ||
{"tableofcontents": extract_titles_from_markdown_input(markdown_collection)} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it would better having this in _init_resources
as this is the place where we initialize the resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. This has been moved to _init_resources.
But this is probably not inducing the proper checking on resources
not being None
since it is breaking again the linting CI test with this type of error
nbconvert/exporters/html.py:269: error: Item "None" of "Optional[Dict[str, Any]]" has no attribute "update" [union-attr]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using update
, you could follow what the rest of the code is doing: resources["tableofcontents"] = extract_titles_from_markdown_input(markdown_collection)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was initially what was used but without any check that resources
was not None
.
Introducing the suggested change leads to this error message
nbconvert/exporters/html.py:269: error: Unsupported target for indexed assignment ("Optional[Dict[str, Any]]") [index]
nbconvert/exporters/html.py:358: error: Name "resources" already defined on line 294 [no-redef]
Maybe the type check in the _init_resources
function is not valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have displaced the None check
condition back at its initial place, in the HTMLExporter
Co-authored-by: martinRenou <[email protected]>
5e3d85e
to
248ddff
Compare
5ce9a04
to
c8483f8
Compare
0238fb3
to
711cee8
Compare
Fix index.html.j2 to restore the style of the table of content.
320d056
to
cdc2743
Compare
…om_notebook_node, include it in the resources dictionary and use it directly in the index.html.j2 template.
9452783
to
de2ff4e
Compare
2117401
to
6fbb968
Compare
c799885
to
5708233
Compare
04fcc39
to
14a3ab8
Compare
0a759d4
to
e833379
Compare
for more information, see https://pre-commit.ci
Add a toc for html and latex exporter.
This PR fixes #1690.
When working on this PR, an correlated issue was opened in jupyterlab jupyterlab/jupyterlab#16795