Skip to content

Commit 9cca27d

Browse files
committed
Add () for methods and functions
1 parent 0548d7b commit 9cca27d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

docs/scripts/post-render.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import glob
3+
import re
34

45
# Print the working directory
56
print("Current working directory:", os.getcwd())
@@ -20,8 +21,28 @@
2021

2122
with open(html_file, "r") as file:
2223
content = file.readlines()
23-
24-
# Replace <h1> tag with a styled version
24+
# If the inner content of the <h1> tag either:
25+
# - has a literal `.` in it, or
26+
# - doesn't start with a capital letter,
27+
# then add `()` to the end of the content of the <h1> tag
28+
for i, line in enumerate(content):
29+
# Use regex to find the h1 tag with potential whitespace variations
30+
h1_match = re.search(r'<h1\s+class="title">', line)
31+
if h1_match:
32+
# Extract the content of the <h1> tag
33+
start = h1_match.end()
34+
end = line.find("</h1>", start)
35+
h1_content = line[start:end].strip()
36+
37+
# Check if the content meets the criteria
38+
if "." in h1_content or (h1_content and not h1_content[0].isupper()):
39+
# Modify the content
40+
h1_content += "()"
41+
42+
# Replace the <h1> tag with the modified content
43+
content[i] = line[:start] + h1_content + line[end:]
44+
45+
# Add a style attribute to the <h1> tag to use a monospace font for code-like appearance
2546
content = [
2647
line.replace(
2748
'<h1 class="title">',

0 commit comments

Comments
 (0)