This commit is contained in:
Eugene Yurtsev
2024-12-22 22:07:59 -05:00
parent 9e31b82d8d
commit f993dfcfcb
2 changed files with 84 additions and 5 deletions
+6 -1
View File
@@ -7,6 +7,7 @@ from mkdocs.structure.files import Files, File
from mkdocs.structure.pages import Page
from notebook_convert import convert_notebook
from generate_api_reference_links import update_markdown_with_imports
logger = logging.getLogger(__name__)
logging.basicConfig()
@@ -111,7 +112,11 @@ def on_page_markdown(markdown: str, page: Page, **kwargs: Dict[str, Any]):
if page.file.src_path.endswith(".ipynb"):
logger.info("Processing Jupyter notebook: %s", page.file.src_path)
markdown = convert_notebook(page.file.abs_src_path)
else:
# Append API reference links to code blocks
# This logic is already applied for notebooks in `convert_notebook`.
# We add it here to apply it to regular markdown files.
markdown = update_markdown_with_imports(markdown)
# Apply highlight comments to code blocks
markdown = _highlight_code_blocks(markdown)
return markdown