Skip to content

Instantly share code, notes, and snippets.

@sspaeti
Created September 26, 2021 08:43
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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