Skip to content

Commit 45a44be

Browse files
committed
Fixed toc links
1 parent 27f5482 commit 45a44be

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

_layouts/manual.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<ul class="nobullet">
8080
{%- for t in page.toc -%}
8181
<li style="padding-left: 2rem;">
82-
<a href='#{{ t | downcase | replace: " ", "-" }}' style="text-decoration: none;">{{ t }}</a>
82+
<a href='#{{ t | downcase | replace: " ", "-" | replace: "/", "" }}' style="text-decoration: none;">{{ t }}</a>
8383
</li>
8484
{%- endfor -%}
8585
</ul>

update.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,18 @@ def generate_toc(file):
258258
data = read_as_string(file)
259259
lines = data.splitlines()
260260
toc = []
261+
within_comment = False
261262
for line in lines:
262-
if line.startswith("# ") or line.startswith("## ") or line.startswith("### "):
263-
heading = line.replace("#", "").replace("'", "").replace("`", "").replace("\"", "").strip()
263+
if line.strip() == "```":
264+
within_comment = not within_comment
265+
elif not within_comment and (line.startswith("# ") or line.startswith("## ") or line.startswith("### ")):
266+
heading = line
267+
heading = heading.replace("#", "")
268+
heading = heading.replace("'", "")
269+
heading = heading.replace("`", "")
270+
heading = heading.replace("\"", "")
271+
heading = heading.strip()
272+
# note: there is some additional stripping done in manual.html
264273
toc.append("\"" + heading + "\"")
265274
return toc
266275

0 commit comments

Comments
 (0)