-
Notifications
You must be signed in to change notification settings - Fork 810
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
toc2: html export -- take into account number_section #810
Conversation
…ter when exporting
Yes, sounds reasonable.
This can be avoided with robust jinja processing, though, right? |
@@ -16,7 +16,7 @@ | |||
<script> | |||
$( document ).ready(function(){ | |||
var cfg={'threshold':6, // depth of toc (number of levels) | |||
'number_sections':true, // sections numbering | |||
'number_sections': "{{nb['metadata']['toc']['number_sections']}}"=="True" ? true : false, // sections numbering |
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.
it would probably be more robust to use something like
'number_sections': {{ 'true' if nb.get('metadata', {}).get('toc', {}).get('number_sections', False) else 'false' }},
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.
Wow. Very nice!
@NicolasWoloszko You will have to re-install the |
@NicolasWoloszko
in a code cell. |
That's working thank you very much ! |
toc2:
|
haha, let's merge now? We can always add further PRs later 😆 |
Yes, we can merge now. I just wanted to finish the work to include the other parameters. |
yeah, sorry, it did make sense to include, I was just getting an itchy trigger finger, so to speak. |
OK, here is a possibility to address #808
Just read the parameter in notebook's metadata and populate the parameter in the export template.
However, this has a drawback and I am not sure that it should be merged: if the metadata toc (the toc section in metadata) does not exist, then conversion fail; even if we try to catch the exception; since actually the exception arises in the jinja2 processing.
I think that it can be useful to convert notebook using the
html_toc
parameter even if they have not be created with toc2 activated, since it still generates the toc in that case. Thoughts?