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

python-markdown install documentation #931

Open galou opened 7 years ago

galou commented 7 years ago

I managed to have python-markdown partly working for exported formats, however, not according to the documentation. The file src/jupyter_contrib_nbextensions/nbextensions/python-markdown/readme.md indicates to modify jupyter_nbconvert_config.py but the file jupyter_nbconvert_config.py is ignored if the jupyter_nbconvert_config.json file exists.

I managed to have python-markdown working by actually deleting the file jupyter_nbconvert_config.py because somehow the configuration lines

  "Exporter": {
    "preprocessors": [
      "jupyter_contrib_nbextensions.nbconvert_support.PyMarkdownPreprocessor"
    ]

where already present in jupyter_nbconvert_config.json.

Please note that I couldn't have python-markdown work when exporting from the notebook but only when exporting with jupyter nbconvert. That's why I wrote partly working.

EDIT: corrected jupyter_nbconvert_config.py into jupyter_nbconvert_config.json.

juhasch commented 7 years ago

You should not need to change configuration files in a proper installation.

The code snippet you show above is JSON, the jupyter_nbconvert_config.pyconfiguration file expects Python. Not sure how this can happen ?

Exporting from the notebook itself is different to using jupyter nbconvert. Hopefully this will improve sometimes. Right now all you can do is set the export options for the notebook in `jupyter_notebook_config.py. You will need to restart the notebook server for any configuration changes to be effective.

Does this help ?

galou commented 7 years ago

You're right, I made an error. I meant: the configuration lines

  "Exporter": {
    "preprocessors": [
      "jupyter_contrib_nbextensions.nbconvert_support.PyMarkdownPreprocessor"
    ]

where already present in jupyter_nbconvert_config.json.

I'm not sure anymore what everything I tried and what worked. I was also testing through the notebook before I realized that the notebook works differently than nbconvert. What I think never worked though was to change the file jupyter_nbconvert_config.py but again this was maybe because I was testing it through the notebook.

I'll try to make a test from a virtual machine to check what happens from a real fresh install. I'll report here. Could it be that the file jupyter_nbconvert_config.json is created by another nbextension, thus neutralizing the configuration of python-markdown in jupyter_nbconvert_config.py?

michaelaye commented 7 years ago

I installed the extension via conda-forge and only have the .json setting in my ~/.jupyter folder, as described above, no .py file. IIRC, json files and python files are both valid means to configure jupyter things, including nbconvert. Please confirm that it absolutely has to be via a python settings file?

michaelaye commented 7 years ago

Also, my system only has the pre_pymarkdown.py file at one location:

/Users/klay6683/miniconda3/pkgs/jupyter_contrib_nbextensions-0.2.7-py36_0/lib/python3.6/site-packages/jupyter_contrib_nbextensions/nbconvert_support/pre_pymarkdown.py

I'm not sure that it could be found there? I don't use PYTHONPATH usually, and many people advise against it, due to potentially hard to debug configurations. Can you confirm that the pre_pymarkdown.py still needs to be copied somewhere else, despite installing via conda-forge?

jcb91 commented 7 years ago

@michaelaye sorry, just seen this. You are right - the json files are the preferred config, and what the conda-forge & the pip package does. The repo install should create/edit jupyter_nbconvert_config.json to correctly use the pre_pymarkdown.py, which should be installed into the site-packages directory of the environment in use at install time, without altering any paths.

Did you get this sorted? The pymarkdown readme may need updating, I guess

michaelaye commented 7 years ago

i think conda just installs everything that i need right now, thanks to conda-forge. ;)

miek770 commented 4 years ago

If I may chip in, the latest doc still explains how one shoud edit jupyter_nbconvert_config.py if there's an issue (but jupyter_nbconvert_config.json is the preferred file, as discussed above).

However, as discussed in #1074, it seems there are issues with nbconvert and python-markdown when it's run from the jupyter notebook interface. Both issues probably aren't fully related (i.e.: #1074 doesn't appear to be caused by a misconfiguration), but they do refer to the same subsection of the documentation.