-
Notifications
You must be signed in to change notification settings - Fork 2
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
02a9a9a
commit e655868
Showing
1 changed file
with
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import markdown | ||
|
||
# List all Markdown files in the repository | ||
markdown_files = [file for file in os.listdir('.') if file.endswith('.md')] | ||
|
||
# Open README.md file to write the consolidated content | ||
with open('README.md', 'w') as readme: | ||
for file_name in markdown_files: | ||
if file_name == "README.md": | ||
print('Skipping README.md') # Added print statement for clarity | ||
else: | ||
with open(file_name, 'r') as md_file: | ||
md_content = md_file.read() | ||
# Convert Markdown to HTML | ||
html_content = markdown.markdown(md_content) | ||
# Write HTML content to a new file | ||
with open(file_name.replace('.md','.html'), 'w') as html_file: | ||
html_file.write(html_content) | ||
# Write content to README.md | ||
readme.write(f"## {file_name}\n\n") | ||
readme.write(md_content) | ||
readme.write('\n\n---\n\n') # Separation between files | ||
|
||
# Convert README.md to HTML separately | ||
with open('README.md', 'r') as md_file: | ||
md_content = md_file.read() | ||
# Convert Markdown to HTML | ||
html_content = markdown.markdown(md_content) | ||
# Write HTML content to a new file | ||
with open('index.html', 'w') as html_file: | ||
html_file.write(html_content) |