toc2: html export -- take into account number_section #810
toc2: html export -- take into account number_section #810jfbercher merged 3 commits intoipython-contrib:masterfrom
Conversation
…ter when exporting
Yes, sounds reasonable.
This can be avoided with robust jinja processing, though, right? |
| $( 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.
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' }},|
@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_tocparameter even if they have not be created with toc2 activated, since it still generates the toc in that case. Thoughts?