-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2378d40
commit 489cd7b
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from bs4 import BeautifulSoup | ||
|
||
# Load the HTML content | ||
with open('index.html', 'r') as file: | ||
soup = BeautifulSoup(file, 'html.parser') | ||
|
||
# Create the new script tag | ||
new_script = soup.new_tag('script', type='module') | ||
new_script.string = ''' | ||
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs"; | ||
for (const element of document.getElementsByClassName("language-mermaid")) { | ||
element.classList.add("mermaid"); | ||
} | ||
mermaid.initialize({ startOnLoad: true }); | ||
''' | ||
|
||
# Append the script tag to the end of the body | ||
soup.body.append(new_script) | ||
|
||
# Save the modified HTML back to the file | ||
with open('index.html', 'w') as file: | ||
file.write(str(soup)) |