From e655868c892e7c757715b0caed06fab93ef1c3d2 Mon Sep 17 00:00:00 2001 From: "Dev. Gautam Kumar" <111997815+devsdenepal@users.noreply.github.com> Date: Thu, 29 Feb 2024 20:47:42 +0545 Subject: [PATCH] Create update_readme.py --- update_readme.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 update_readme.py diff --git a/update_readme.py b/update_readme.py new file mode 100644 index 0000000..9f07681 --- /dev/null +++ b/update_readme.py @@ -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)