Python--Convert Markdown To HTML

Posted by: bart30508 | in Python | 11 months ago |

#13 Issue open: Python--Convert Markdown To HTML

Labels: Python

MaxwellBest opened issue at 2021-06-20 14:57:

主要的Script是這段:

```
import markdown

with open("D:\BlogBackup\Github-export\Engineerblog\Engineerblogbackup.md", 'r',encoding="utf-8") as f:
    text = f.read()
    html = markdown.markdown(text)

with open("D:\BlogBackup\Github-export\Engineerblog\Engineerblogbackup.html", 'w',encoding="utf-8") as f:
    f.write(html)
```

以下串成迴圈跑某Folder:

```
from os import listdir
from os.path import isfile, join
import os
import markdown
mypath = "D:\BlogBackup\HackMD-export"
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
for i in onlyfiles:
    mdfile = "/BlogBackup/HackMD-export/"+str(i)
    htmlfile =  "/BlogBackup/HackMD-export/HackMDToHtml/"+str(i)[:-2]+"html"
    with open(mdfile, 'r',encoding="utf-8") as f:
        text = f.read()
        html = markdown.markdown(text)

    with open(htmlfile, 'w',encoding="utf-8") as f:
        f.write(html)

```

Reference: https://www.digitalocean.com/community/tutorials/how-to-use-python-markdown-to-convert-markdown-text-to-html

Currently unrated
 or 

Subscribe

* indicates required

Recent Posts

Archive

2022
2021

Categories

Apache 1

Data Science 2

Dbfit 1

Design Pattern 1

Devops 3

DigitalOcean 1

Django 1

English 3

Excel 5

Flask 3

Git 1

HackMD 1

Heroku 1

Html/Css 1

Linux 4

Machine Learning 2

Manufacture 1

Mezzanine 18

Oracle 1

Postgresql 7

PowerBI 4

Powershell 4

Python 21

SEO 2

SQL Server 51

SQLite 1

Windows 1

database 8

work-experience 1

其他 1

自我成長 1

資料工程 1

Tags

SEO(1) Github(2) Title Tag(2) ML(1) 李宏毅(1) SQL Server(18) Tempdb(1) SSMS(1) Windows(1) 自我成長(2) Excel(1) python Flask(1) python(5) Flask(2)

Authors

bart30508 (146)

Feeds

RSS / Atom

Python--Convert Markdown To HTML

© COPYRIGHT 2011-2022. Max的文藝復興. ALL RIGHT RESERVED.