diff --git a/myst_nb/execution.py b/myst_nb/execution.py index 93232234..ffbcb5d6 100644 --- a/myst_nb/execution.py +++ b/myst_nb/execution.py @@ -10,10 +10,11 @@ """ import os +import re import tempfile from datetime import datetime from pathlib import Path -from typing import List, Optional, Set +from typing import Iterable, List, Optional, Set import nbformat as nbf from jupyter_cache import get_cache @@ -225,8 +226,11 @@ def is_valid_exec_file(env: BuildEnvironment, docname: str) -> bool: doc_path = env.doc2path(docname) if doc_path in env.nb_excluded_exec_paths: return False - extension = os.path.splitext(doc_path)[1] - if extension not in env.nb_allowed_exec_suffixes: + matches = tuple( + re.search(re.escape(suffix) + "$", doc_path) + for suffix in env.nb_allowed_exec_suffixes + ) + if not any(matches): return False return True @@ -323,7 +327,9 @@ def _converter(path): return result -def nb_has_all_output(source_path: str, nb_extensions: List[str] = (".ipynb",)) -> bool: +def nb_has_all_output( + source_path: str, nb_extensions: Iterable[str] = (".ipynb",) +) -> bool: """Determine if the path contains a notebook with at least one output.""" has_outputs = False ext = os.path.splitext(source_path)[1]