Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert exported HTML pages to Markdown pages recursively where you start this script from
"Convert exported HTML pages to Markdown pages recursively where you start this script from"
import os
from markdownify import markdownify
from pathlib import Path
for dirpath, dirs, files in os.walk("."):
print("--" + dirpath)
for filename in files:
if filename.endswith(".html"):
print(f"filename: {filename}")
file = open(os.path.join(dirpath, filename), "r").read()
html = markdownify(file, heading_style="ATX")
markdown_file = open(os.path.join(dirpath, filename.replace(".html", ".md")), "w")
n = markdown_file.write(html)
markdown_file.close()
else:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment