NBExtension: Document tools don't work with IPython3

Issue #215 resolved
Michael Forbes created an issue

It looks like the document tools - generating ToC, moving sections, etc. - no longer works with the development version of IPython (3.0). Probably due to changes in the nbformat. Can this be fixed - they are very useful tools!

See also Issue #208.

Comments (21)

  1. Doug Blank

    Thanks! Yes, indeed, we need to revise most of these (again) to work with IPython 3. Should see some revisions this week, as the semester is beginning, and I need these too :)

  2. Doug Blank

    @mforbes Please try either installing from git or from the download page. All extensions should be working with IPython 2 or 3. May still be some bugs. Please report back if issues. Thanks!

  3. Doug Blank

    You may need to clear your javascript cache. In chrome, if you open the Javascript console and right click on "reload" you can select "hard reset" or similar. All of the extensions are working for me now. Note that any of these that depend on headings, will break up the markdown so that headings are in their own cells.

  4. Michael Forbes reporter

    Aha. IPython's ipython install-nbextension now by default puts things in /usr/local/share/jupyter/nbextensions whereas before they went to ~/.ipython/nbextensions/. I forgot about the old files in my home directory and these were overriding the new extensions in the /usr/local/share/jupyter/nbextensions.

    It would be good to add a short note about this with the install instructions.

    I will let you know if I notice any problems, but from a quick test it seems that everything works now. Thanks!

  5. Michael Forbes reporter

    Everything seems to work now with IPython: 53085e7a7f85d8d02e2bb765a2131faa3184b8f9

    Be sure to remove all old versions before installing, including both locations:

    • /usr/local/share/jupyter/nbextensions
    • ~/.ipython/nbextensions

    The latter has precedence and can be specified using the --user flag when calling ipython install-nbextension --user. The extensions can be installed with:

    ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-spell-check-1.0.zip
    ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-document-tools-1.0.zip
    ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-cell-tools-1.0.zip
    
  6. Michael Forbes reporter
    • changed status to open

    The header tools have some issues - in particular, if there is text in with the header (which seems to be the intended default behaviour with the IPython 3.0) that text seems to be actually lost, not just split off when using the numbered headers.

  7. Doug Blank

    I think that was fixed, but I think I forgot to update the .zip files. I'll do that later today. Thanks! 9you can also install single .js files directly from the repository, FYI).

  8. Michael Forbes reporter

    I think I am using the latest files from master. Can you point me to the relevant change and I will make sure I am loading the latest version?

    I am loading the version of calico-document-tools.js with line 48 (fbfe84ec83e)

                    if (current.trim() !== "") {
    

    which appears to be the latest.

    The problem is with a cell like:

    # 1. Heading
    
    This text gets lost when numbering
    

    When numbering, the text gets lost.

    If a cell does not start with a header, then it is simply ignored:

    This text stays.
    
    #Heading not numbered or added to ToC.
    
    This text stays.
    

    It would probably be very useful if the document tools would break these cells apart to (especially for newer users not used to the convention of one cell per header). Ideally, you would pop up a warning message saying that the convention is to keep header's in their own cells, then make the change.

    (Sorry, I have no js skills at the moment so am not sure how hard this is.)

  9. Michael Forbes reporter

    I think I might be mistaken about the headers in IPython - they probably still should be separate cells. Thus breaking out the headers is probably the best behaviour, but loosing context is not:-) (The development version reverted to hashes and lost the header cell types, but I can't find any recent discussions that revert the suggestion to keep header cells on their own).

    Can you find and split out all headers, with a warning (as I suggested above)? I think that would be the best behaviour when numbering and/or generating the ToC.

  10. Michael Forbes reporter

    One more request that is probably very hard - can you provide an undo? (Probably only an issue while this bug remains, but when my text when missing, I really wanted one!)

    Let me know if you want me to open a new issue with the warning box/breaking enhancement request.

    Thanks!

  11. Doug Blank

    Ok, this deleting of text is fixed. I think that there are still a couple of issues in Table of Contents. I'll try to track those down. If you can narrow down any misbehaving function, please post a small repeatable bit of text.

    As for undelete... yes, that is a bigger task. The IPython team should fix that. Having multiple checkpoints would help.

    Thanks!

  12. Michael Forbes reporter

    There are still some issues that I see:

    1. When the cells are broken up, the markdown cell below the header is expanded in editing mode.
    2. When cells end with a code block, the code block gets lost (and the fence appears on its own in a following block).
    This fails:
    
    ```bash
    ipython notebook
    ```
    
  13. Michael Forbes reporter

    I added a suggested fix as pull request #5. There is still a stray = that I think should be a +=. Also, I noticed that the code will strip out blank lines which can change formatting. I also set the inserted cells as rendered, but maybe this should depend on the initial render state of the cell being split. Finally, I allow for nested fences (as needed in the previous comment to demonstrate a fence:-)

  14. Doug Blank

    Thanks! The changes look good, and I agree with your decisions. Is there anything that is still left to fix that you know about? (We'll move these nbextensions out of this repo eventually... that is a large download for just these little Javascript files).

  15. Michael Forbes reporter

    One more small bug - my current check fails with a blank fence. I will post a fix in minute.

  16. Log in to comment