Open charlet-antoine opened 4 years ago
Both jupyter-book and fastpages support this feature.
The only way that worked for me was this:
IPYNB_PREPROCESSORS=[
nbconvert.preprocessors.ExecutePreprocessor(timeout=300),
nbconvert.preprocessors.RegexRemovePreprocessor(patterns=['.*PREAMBLE.*'])]
Then every cell that contains PREAMBLE
is executed but removed from the pelican output.
Example:
# PREAMBLE
import numpy, pandas, seaborn
...
Although it would be nice to have all (previous) cells execute when giving Subcells: [2, None]
in the metadata.
I have achieved removing cell from the pelican output with removing cell by assigning given tag and configuring preprocessor.
Steps:
remove_cell
to the cell that has to be removed (in Jupyter notebook use: View -> Cell Toolbar -> Tags)pelicanconf.py
:
from nbconvert.preprocessors import TagRemovePreprocessor
from traitlets.config import Config
c = Config()
c.TagRemovePreprocessor.remove_cell_tags = ("remove_cell",)
c.TagRemovePreprocessor.enabled = True
IPYNB_PREPROCESSORS=[TagRemovePreprocessor(config=c)]
Reference: Removing cells, inputs, or outputs - nbconvert documentation
Hi everyone,
I'm a new user of pelican and this plugin and I was wondering if it was possible to hide a specific notebook cell to make it non visible once my notebook is published with pelican. One of my use cases is that usually my notebook start by the classic: import pandas as pd import numpy as np import matplotlib.pyplot as plt
etc... but I see really few value making this cell visible in my blog posts. Is this feature already implemented in the plugin? Otherwise do you have any ideas how I could do that easily ?
Thank you by advance for your help.
Antoine,