Skip to content

Commit

Permalink
Merge pull request #32 from TUW-GEO/dev
Browse files Browse the repository at this point in the history
fix references
  • Loading branch information
MartinSchobben authored Jan 2, 2025
2 parents fa4a45e + f7bb38d commit 26e676c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/ \
Expand Down
22 changes: 10 additions & 12 deletions src/eo_datascience/clean_nb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import nbformat
from pathlib import Path
import re
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 26e676c

Please sign in to comment.