Skip to content

Fix navigation links to use .ipynb extension instead of .md #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/doc_builder/build_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,22 @@ def resolve_links(doc_folder, package, mapping, page_info):
with open(file, "r", encoding="utf-8") as reader:
content = reader.read()
content = resolve_links_in_text(content, package, mapping, page_info)
# Fix notebook links to use .ipynb extension
content = fix_notebook_links(content)
with open(file, "w", encoding="utf-8") as writer:
writer.write(content)


def fix_notebook_links(content):
"""
Fix navigation links at the bottom of notebooks to use .ipynb extension instead of .md.
"""
# Replace .md with .ipynb in Previous/Next navigation links
content = content.replace('Previous](.md)', 'Previous](.ipynb)')
content = content.replace('Next](.md)', 'Next](.ipynb)')
return content


def build_notebooks(doc_folder, notebook_dir, package=None, mapping=None, page_info=None):
"""
Build the notebooks associated to the MDX files in the documentation with an [[open-in-colab]] marker.
Expand Down