# credit to the Stack Overflow user in the source link
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
new_parser.parse_html_file("html_filename", "docx_filename")
# Files extensions not needed, but tolerated
import mammoth
custom_styles = "b => i"
with open(input_filename, "rb") as docx_file:
result = mammoth.convert_to_html(docx_file, style_map = custom_styles)
text = result.value
with open('output.html', 'w') as html_file:
html_file.write(text)