jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.72k stars 563 forks source link

CSSHTMLHeaderPreprocessor.style=<name> breaks with 6.x.x #1507

Open jaymegordo opened 3 years ago

jaymegordo commented 3 years ago

Description

I use --CSSHTMLHeaderPreprocessor.style=solarized-dark for example when exporting a notebook to modify the code syntax highlighting. In >6.0.0 this fails (silently) and only uses the default syntax. I've tested by both completely reinstalling everything in a new venv (still fails), then downgrading to 5.6.1 (works again).

Is there any way to confirm that nbconvert can find the correct pygments styles?

Reproduce

Nbconvert version: 6.0.7

jupyter related packages: Name Version
ipykernel 5.3.4
ipython 7.19.0
ipython_genutils 0.2.0
jinja2 2.11.2
jupyter_client 6.1.11
jupyter_core 4.7.0
jupyter_server 1.2.2
jupyterlab 3.0.5
jupyterlab_pygments 0.1.2
jupyterlab_server 2.1.3
nbclassic 0.2.6
nbclient 0.5.1
nbconvert 6.0.7
nbformat 5.1.2
pygments 2.7.4
JPinSPACE commented 3 years ago

I am experiencing the same issue. When I run nbconvert with different styles and then diff the files there is no difference.

Vaibhav-Ankolekar commented 3 years ago

I got the solution for this after a lot of time This solution contains changing Python Library Files (not recommended) Step 1 : Go to .\Python\Python39\Lib\site-packages\nbconvert\preprocessors Step 2: Open csshtmlheader.py with any text-editor Step 3: In class CSSHTMLHeaderPreprocessor there will be style variable, which will have default_value=JupyterStyle, just change value after = to any style you want but in quotes( inverted commas ) for example : default_value='vs' Step 4: Save the file

Jupyter Notebook

Now, you can run the command jupyter nbconvert --to html notebook.ipynb, you do not need to add --CSSHTMLHeaderPreprocessor.style=<name>, because by default it will be given the style you mention in csshtmlheader.py. I don't know why the tag is not working as stated in Jupyter Docs

For available styles run this command: pygmentize -L styles

finale80 commented 3 years ago

@RagnosVA your methods works, but obviously hardwire you to a specific style defeating the purpose of the command line option

I opened a PR with a generalised fix https://github.com/jupyter/nbconvert/pull/1548