mirror of
https://github.com/Lerking/md2doc.git
synced 2025-07-20 23:21:03 +02:00
18 lines
420 B
Python
18 lines
420 B
Python
import markdown
|
|
from docx import Document
|
|
from htmldocx import HtmlToDocx
|
|
|
|
def read_md():
|
|
with open('./test-data/markdown_sample.md', 'r') as f:
|
|
text = f.read()
|
|
return markdown.markdown(text)
|
|
|
|
def write_doc(text):
|
|
doc = Document()
|
|
parser = HtmlToDocx()
|
|
parser.add_html_to_document(text, doc)
|
|
|
|
doc.save("./test-data/markdown_sample.docx")
|
|
|
|
if __name__=="__main__":
|
|
write_doc(read_md()) |