diff --git a/Makefile b/Makefile index ed10c20..f2e5977 100644 --- a/Makefile +++ b/Makefile @@ -56,11 +56,15 @@ preview: $(CONDA_ENV)/envs/eo-datascience $(CONDA_ENV_DIR) $(KERNEL_DIR) $(CONDA_ACTIVATE) eo-datascience - mkdir -p _preview/notebooks python -m pip install -e . + cp ./chapters/references.bib ./_preview/notebooks/ wget https://raw.githubusercontent.com/TUW-GEO/eo-datascience-cookbook/refs/heads/main/README.md -nc -P ./_preview + wget https://raw.githubusercontent.com/TUW-GEO/eo-datascience-cookbook/refs/heads/main/_config.yml -nc -P ./_preview wget https://raw.githubusercontent.com/TUW-GEO/eo-datascience-cookbook/refs/heads/main/notebooks/how-to-cite.md -nc -P ./_preview/notebooks + wget -O - https://github.com/TUW-GEO/eo-datascience-cookbook/archive/main.tar.gz | tar xz -C ./_preview/notebooks --strip=2 "eo-datascience-cookbook-main/notebooks/images" render_sfinx_toc ./_preview clean_nb ./notebooks ./_preview/notebooks - jupyter-book build ./_preview ; jupyter-book build ./_preview + jupyter-book build ./_preview + jupyter-book build ./_preview clean: rm --force --recursive .ipynb_checkpoints/ **/.ipynb_checkpoints/ _book/ \ diff --git a/src/eo_datascience/clean_nb.py b/src/eo_datascience/clean_nb.py index 4554bd3..1668ae5 100644 --- a/src/eo_datascience/clean_nb.py +++ b/src/eo_datascience/clean_nb.py @@ -1,4 +1,3 @@ -import os import nbformat from pathlib import Path import re @@ -45,11 +44,12 @@ def convert_bibliography(nb_path="./notebooks/references.ipynb", out=None, save= nb_path = Path(nb_path) if nb_path.exists(): nb = nbformat.read(nb_path, as_version=4) - nb.cells[0].source = """# References - - ```{bibliography} - ``` - """ + nb.cells[0].source = \ +"""# References +```{bibliography} +:style: plain +``` +""" # Save the notebook nb_path = substitute_path(nb_path, nb_path.parent, out) if save: @@ -97,12 +97,10 @@ def convert_refs(dir="./notebooks", out=None, save=True): # Load the notebook nb = nbformat.read(nb_path, as_version=4) for i in range(len(nb.cells)): - if i != 0: - if nb.cells[i]["cell_type"] == "markdown": - nb.cells[i].source = quarto_ref_figure_replace(nb.cells[i].source) - nb.cells[i].source = quarto_ref_person_replace(nb.cells[i].source) - nb.cells[i].source = quarto_ref_time_replace(nb.cells[i].source) - nb + if nb.cells[i]["cell_type"] == "markdown": + nb.cells[i].source = quarto_ref_figure_replace(nb.cells[i].source) + nb.cells[i].source = quarto_ref_person_replace(nb.cells[i].source) + nb.cells[i].source = quarto_ref_time_replace(nb.cells[i].source) # Save the notebook nb_path = substitute_path(nb_path, dir, out)