Skip to content

Commit e31afa1

Browse files
WEB: Add table of contents to the Ecosystem (#61655)
1 parent 257b820 commit e31afa1

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

web/pandas/community/ecosystem.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Ecosystem
22

3+
[TOC]
4+
35
Increasingly, packages are being built on top of pandas to address
46
specific needs in data preparation, analysis and visualization. This is
57
encouraging because it means pandas is not only helping users to handle

web/pandas/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ main:
1414
- pandas_web.Preprocessors.home_add_releases
1515
- pandas_web.Preprocessors.roadmap_pdeps
1616
markdown_extensions:
17-
- toc
1817
- tables
1918
- fenced_code
2019
- meta

web/pandas_web.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import feedparser
4343
import jinja2
4444
import markdown
45+
from markdown.extensions.toc import TocExtension
4546
from packaging import version
4647
import requests
4748
import yaml
@@ -470,29 +471,14 @@ def main(
470471
with (source_path / fname).open(encoding="utf-8") as f:
471472
content = f.read()
472473
if extension == ".md":
473-
if len(fname.parts) > 1 and fname.parts[1] == "pdeps":
474-
from markdown.extensions.toc import TocExtension
475-
476-
body = markdown.markdown(
477-
content,
478-
extensions=[
479-
# Ignore the title of the PDEP in the table of contents
480-
TocExtension(
481-
title="Table of Contents",
482-
toc_depth="2-3",
483-
permalink=" #",
484-
),
485-
"tables",
486-
"fenced_code",
487-
"meta",
488-
"footnotes",
489-
"codehilite",
490-
],
491-
)
492-
else:
493-
body = markdown.markdown(
494-
content, extensions=context["main"]["markdown_extensions"]
495-
)
474+
toc = TocExtension(
475+
title="Table of Contents",
476+
toc_depth="2-3",
477+
permalink=" #",
478+
)
479+
body = markdown.markdown(
480+
content, extensions=context["main"]["markdown_extensions"] + [toc]
481+
)
496482
# Apply Bootstrap's table formatting manually
497483
# Python-Markdown doesn't let us config table attributes by hand
498484
body = body.replace("<table>", '<table class="table table-bordered">')

0 commit comments

Comments
 (0)