python转换markdown为html表格高亮

2024-02-26 15:02 python转换markdown为html表格高亮已关闭评论

1. 安装markdwon

安装markdwon,执行命令

pip install markdown

2. 转换为html

读取.md文件(注意中文),指定encoding编码为UTF-8

with open(file_path, 'r', encoding='UTF-8') as file:
    text = file.read()
    html = markdown.markdown(text)
    print(html)
    return html

3. 表格高亮

添加extensions=['tables']

with open(file_path, 'r', encoding='UTF-8') as file:
    text = file.read()
    html = markdown.markdown(text,extensions=['tables'])
    print(html)
    return html

当前文章价值4.07元,扫一扫支付后添加微信提供帮助!(如不能解决您的问题,可以申请退款)

你可能感兴趣的文章

来源:每日教程每日一例,深入学习实用技术教程,关注公众号TeachCourse
转载请注明出处: https://teachcourse.cn/3050.html ,谢谢支持!

资源分享

分类:python 标签:,
python获取路径中的文件名或扩展名 python获取路径中的文件名或扩展
Windows 10系统安装Tesseract-OCR并配置TESSERACT_HOME和TESSDATA_PREFIX实用教程 Windows 10系统安装Tesseract-
013-wp-json wp v2 posts接口 获取文章内容的方法,存在漏洞:其他用户也会直接调用该接口获取内容,如何防止 013-wp-json wp v2 posts接口 获
浅谈Eclipse插件ADT 浅谈Eclipse插件ADT

评论已关闭!