Skip to content

Commit 8e8875b

Browse files
committed
Merge branch 'dev-from-macmini' of github.com:myoshi2891/AlgorithmStudy into dev-from-macmini
# Conflicts: # public/index.html
2 parents 60ae269 + 8237ef7 commit 8e8875b

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

generate_index.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,22 @@ def copy_vendor_files(self, output_dir: str) -> None:
8484

8585
def rewrite_html_content(self, content: str) -> str:
8686
"""
87-
Rewrite CDN asset URLs in HTML to local /vendor/ paths.
88-
89-
Replaces known external CDN links (React, Babel, Tailwind, PrismJS, FontAwesome, etc.) with corresponding /vendor/... paths and removes `integrity` and `crossorigin` attributes from `<link>` and `<script>` tags that reference those local vendor files.
90-
87+
Rewrite HTML to replace known CDN asset URLs with local `/vendor/` paths and remove SRI and crossorigin attributes from tags that reference those local assets.
88+
9189
Parameters:
9290
content (str): HTML document content to rewrite.
93-
91+
9492
Returns:
95-
str: The HTML content with matching CDN URLs substituted by local vendor URLs and SRI/crossorigin attributes stripped for vendored assets.
93+
str: HTML content with matching CDN URLs substituted by local `/vendor/` URLs and `integrity`/`crossorigin` attributes removed from tags that reference `/vendor/`.
94+
"""
95+
"""
96+
Remove `integrity` and `crossorigin` attributes from a matched <link> or <script> tag when it references a `/vendor/` path.
97+
98+
Parameters:
99+
match (typing.Match[str]): A regex match whose matched text is the full HTML tag.
100+
101+
Returns:
102+
str: The tag text with `integrity` and `crossorigin` attributes removed if the tag contains `/vendor/`, otherwise the original tag text.
96103
"""
97104
replacements = [
98105
# React
@@ -125,13 +132,13 @@ def rewrite_html_content(self, content: str) -> str:
125132
# Strip integrity and crossorigin attributes from tags referencing local /vendor/ files
126133
def strip_sri(match: re.Match[str]) -> str:
127134
"""
128-
Remove Subresource Integrity (`integrity`) and `crossorigin` attributes from an HTML <link> or <script> tag if the tag references a `/vendor/` path.
129-
135+
Remove `integrity` and `crossorigin` attributes from an HTML `<link>` or `<script>` tag that references a `/vendor/` path.
136+
130137
Parameters:
131-
match (re.Match): A regex match object whose matched text is the full HTML tag.
132-
138+
match (typing.Match[str]): Regex match whose matched text is the full HTML tag to process.
139+
133140
Returns:
134-
str: The original tag text with `integrity` and `crossorigin` attributes removed when the tag contains `/vendor/`; otherwise the original tag text unchanged.
141+
str: The tag text with `integrity` and `crossorigin` attributes removed if the tag contains `/vendor/`, otherwise the original tag text.
135142
"""
136143
tag_text = match.group(0)
137144
if '/vendor/' in tag_text:

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ <h1 class="site-title">
793793

794794
<footer>
795795
<span class="footer-icon">🧪</span>
796-
Generated on 2026-02-26 06:59:15 UTC
796+
Generated on 2026-02-26 07:00:38 UTC
797797
</footer>
798798

799799
<script>

0 commit comments

Comments
 (0)