File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 11import os
22import glob
3+ import re
34
45# Print the working directory
56print ("Current working directory:" , os .getcwd ())
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">' ,
You can’t perform that action at this time.
0 commit comments