Skip to content

Commit

Permalink
Create update_readme.py
Browse files Browse the repository at this point in the history
  • Loading branch information
devsdenepal authored Feb 29, 2024
1 parent 02a9a9a commit e655868
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions update_readme.py
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)

0 comments on commit e655868

Please sign in to comment.