From 97412e75076ffc0e4f5b468aebe886a2683607c8 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 13 Jun 2025 19:04:22 +0200 Subject: [PATCH] WEB: Add table of contents to the Ecosystem --- web/pandas/community/ecosystem.md | 2 ++ web/pandas/config.yml | 1 - web/pandas_web.py | 32 +++++++++---------------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/web/pandas/community/ecosystem.md b/web/pandas/community/ecosystem.md index 1ebd4f3d3f1dc..d16e25edfc9e2 100644 --- a/web/pandas/community/ecosystem.md +++ b/web/pandas/community/ecosystem.md @@ -1,5 +1,7 @@ # Ecosystem +[TOC] + Increasingly, packages are being built on top of pandas to address specific needs in data preparation, analysis and visualization. This is encouraging because it means pandas is not only helping users to handle diff --git a/web/pandas/config.yml b/web/pandas/config.yml index bdc76ec22a310..3ff22d574f171 100644 --- a/web/pandas/config.yml +++ b/web/pandas/config.yml @@ -14,7 +14,6 @@ main: - pandas_web.Preprocessors.home_add_releases - pandas_web.Preprocessors.roadmap_pdeps markdown_extensions: - - toc - tables - fenced_code - meta diff --git a/web/pandas_web.py b/web/pandas_web.py index eca53178426dc..dec03d00574f1 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -42,6 +42,7 @@ import feedparser import jinja2 import markdown +from markdown.extensions.toc import TocExtension from packaging import version import requests import yaml @@ -470,29 +471,14 @@ def main( with (source_path / fname).open(encoding="utf-8") as f: content = f.read() if extension == ".md": - if len(fname.parts) > 1 and fname.parts[1] == "pdeps": - from markdown.extensions.toc import TocExtension - - body = markdown.markdown( - content, - extensions=[ - # Ignore the title of the PDEP in the table of contents - TocExtension( - title="Table of Contents", - toc_depth="2-3", - permalink=" #", - ), - "tables", - "fenced_code", - "meta", - "footnotes", - "codehilite", - ], - ) - else: - body = markdown.markdown( - content, extensions=context["main"]["markdown_extensions"] - ) + toc = TocExtension( + title="Table of Contents", + toc_depth="2-3", + permalink=" #", + ) + body = markdown.markdown( + content, extensions=context["main"]["markdown_extensions"] + [toc] + ) # Apply Bootstrap's table formatting manually # Python-Markdown doesn't let us config table attributes by hand body = body.replace("", '
')