feat: add UMass Amherst theme support, implement HTML snippet management system, and update page rendering logic
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import sys
|
||||
|
||||
file_path = "/home/x79/sisvietnamvn_01/sisvietnamvn_Trang chính thức hiện tại/UMass Amherst _ UMass Amherst.html"
|
||||
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
start_idx = -1
|
||||
for i, line in enumerate(lines):
|
||||
if '<div class="content-top">' in line:
|
||||
start_idx = i
|
||||
break
|
||||
|
||||
if start_idx == -1:
|
||||
print("Could not find <div class=\"content-top\">")
|
||||
sys.exit(1)
|
||||
|
||||
extracted = []
|
||||
div_count = 0
|
||||
found_start = False
|
||||
|
||||
for line in lines[start_idx:]:
|
||||
# Simple tag counting to find the matching closing div
|
||||
# Note: this is a naive counter, it doesn't account for HTML comments or script tags containing strings that look like tags,
|
||||
# but it usually works well for standard HTML layout sections.
|
||||
div_count += line.count("<div")
|
||||
div_count -= line.count("</div")
|
||||
|
||||
extracted.append(line)
|
||||
if div_count == 0:
|
||||
break
|
||||
|
||||
output_path = "src/main/resources/templates/themes/umass/content-top.html"
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
f.writelines(extracted)
|
||||
print(f"Extracted to {output_path}")
|
||||
Reference in New Issue
Block a user