ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.24k stars 807 forks source link

ToC cell + LaTeX in a heading + HTML export #635

Open PeterMinin opened 8 years ago

PeterMinin commented 8 years ago

This combination (with the table of contents generated with ToC2) leads to a broken html page: the LaTeX part of the heading "runs away" from its place and floats next to the table of contents. See the attachment for an example. ToC cell + LaTeX in a heading + HTML export.zip

jfbercher commented 8 years ago

If you haven't done it yet, please update to the last version. Then try jupyter nbconvert FILE.ipynb --template toc2 (see docs in README) in your case

jupyter nbconvert "ToC cell + LaTeX in a heading + HTML export.ipynb" --template toc2

It should give you the attached file.

ToC cell + LaTeX in a heading + HTML export.html.zip

jfbercher commented 7 years ago

@PeterMinin Any progress regarding this issue? Does it works as intended now?

It is now also possible to export to html with toc embedded using jupyter nbconvert --to html_toc FILE.ipynb

PeterMinin commented 7 years ago

I'm really sorry about leaving it like this. At the time, I was indeed on an older version. After updating I still had some problems, partially caused by my setup, so I wanted to figure everything out there before I could say anything definite. Should've known it would take an infinite time... :)

Right now, testing on a different system in a fresh conda env with the latest master version, things are better, but there are still problems. I found an apparently reproducible case.

Say, I have 3 headings with LaTeX. If I start editing all of them and then format them at the same time using Cell -> Run all, I get a good output in HTML (right), but the notebook's ToC sidebar displays some headings unformatted (left).

But if I start editing the headings one by one, only the last one is displayed correctly in HTML.

Before the Nov 16 changes (the 0.2.2 release on conda-forge still doesn't have them for some reason) I was also sometimes getting a red "[Math Processing Error]" instead of LaTeX, which is also how my old broken HTML is now displayed.

jcb91 commented 7 years ago

the 0.2.2 release on conda-forge still doesn't have them for some reason

I guess you say this because 0.2.2 only got released today on conda-forge? I'm afraid the release schedule is quite a bit behind master at the moment!

PeterMinin commented 7 years ago

Not really, yesterday I noticed it was on 0.2.1, so I checked again today and it downloaded 0.2.2.

PeterMinin commented 7 years ago

Apparently I didn't reload something. I checked again, and the changes are there. Sorry for the confusion.

jcb91 commented 7 years ago

I checked again today and it downloaded 0.2.2

Yeah, I only just got around to pushing 0.2.2 to conda-forge today. The forge recipe pulls from pypi.io rather than pypi.python.org (at the request of the forge folks), and since pypi.io gets source at a delay from pypi.python.org (variable, from minutes to days, I don't know why), the conda recipe updates lag behind the pip uploads. This release was also complicated by the fact I needed to rerender the recipe for a newer conda-smithy version, and that got delayed by long delays in Travis OSX build infrastructure over the last couple of days.

If you want a bleeding-edge version through conda, you can build the recipe in this repo using the method in our condarecipe tox env, which is used for the travis conda-recipe build:

conda build --channel conda-forge conda.recipe
conda install --channel conda-forge --use-local jupyter_contrib_nbextensions

or the similar

conda build --channel conda-forge conda.recipe
conda update --channel conda-forge --use-local jupyter_contrib_nbextensions

to update. Version numbers should be compatible with the main conda-forge releases.

jfbercher commented 7 years ago

Concerning the "$\LaTeX$ issue mentioned above, I have been able to reproduce transiently (but only transiently). I think that this might be a mathjax related issue, as also shown by the [Math Processing Error] which is a mathjax error message. Perhaps of course that it is not standard/supported to include mathjax maths in links and that we should filter out maths from toc headers? [though I remember that we found useful to enable it... ]

jcb91 commented 7 years ago

Perhaps of course that it is not standard/supported to include mathjax maths in links

I doubt it's unsupported, after all, html links should be able to contain almost any other tag, no? Certainly imd, div, span and the like which I'd think would likely be used MathJax.

MathJax rendering in notebooks is (I think? I forget...) asynchronous though, which may be related.

jfbercher commented 7 years ago

Yes, certainly asynchronous since the literal maths $\LaTeX$ are first shown in the toc and then rendered. The maths duplication issue seems similar to this issue.

PeterMinin commented 7 years ago

@jcb91 Actually, after all, the conda-forge version of 0.2.2 does have an old version of toc2. If you download jupyter_contrib_nbextensions-0.2.2-py27_0.tar.bz2 and look into lib/python2.7/site-packages/jupyter_contrib_nbextensions/nbextensions/toc2/README.md, the last line there starts with - @jfbercher septemeber 21. Last time I was confused by the copy of the extension I had left in .local/share/jupyter from an installation via pip and jupyter ... install --user. Also, thank you for the instructions.

jcb91 commented 7 years ago

Actually, after all, the conda-forge version of 0.2.2 does have an old version of toc2 [...] the last line there starts with - @jfbercher septemeber 21.

Right, but that is the case also for 0.2.2. The 0.2.2 version is old compared to the current repo master. We just haven't yet had a newer version on pip/anaconda that incorporates latest changes to toc2 (in fact, they seem to be the first PR merged after 0.2.2 in bd65972332af73377c2fef7ec2586dfe3d28e28c). Essentially, I need to put 0.2.3 out :blush:

Last time I was confused by the copy of the extension I had left in .local/share/jupyter

yeah, it gets confusing managing versions!

PeterMinin commented 7 years ago

Of course, the linear log view... I was judging by the fact that https://github.com/ipython-contrib/jupyter_contrib_nbextensions/commit/a61750af97d96e00a12bb012f66642d98b4a3bf5 is below https://github.com/ipython-contrib/jupyter_contrib_nbextensions/commit/0cdb295c9f667186f07d753bf260ef14d89a9a8b in GitHub's log...

jcb91 commented 7 years ago

I was judging by the fact that a61750a is below 0cdb295 in GitHub's log...

not sure which log you mean here?

I've rolled a 0.2.3 release on pypi, but conda build will as usual be delated until the source dist is available on pypi.io

PeterMinin commented 7 years ago

Thank you. I meant the Commits page, an analog of git log.

jcb91 commented 7 years ago

I meant the Commits page, an analog of git log.

Ah, neat, I'd never noticed that before! I've always used SourceTree / GitKraken :) Yeah, the log is kinda confusing in its ordering looked at like that...

PeterMinin commented 7 years ago

Same reason why I didn't expect this kind of magic, I always use at least git log --graph.

Ok, enough with the off-topic, sorry @jfbercher :)