【md2html python 将 Markdown 文本转换为 HTML】

测试md文本

python 复制代码
md_text = """
# title

## subtitle

\```python
print("Hello, World!")
\```

- item 1

| Header 1 | Header 2 |
|----------|----------|
| Row 1 Col 1 | Row 1 Col 2 |

- item 2

> This is a blockquote.

### Subsubtitle

This is a paragraph with **bold text** and *italic text*.

欢迎使用 Markdown 语法来编写文档。以下是一些常见的 [Markdown](https://test.html) 特性:

""".strip()

基于markdown

python 复制代码
# pip install markdown -U

import markdown
from IPython.display import display, HTML

converted = markdown.markdown(md_text, extensions=["tables", "fenced_code"], output_format="html")

html_text = f"""<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body>
{converted}
</body>
</html>"""
display(HTML(html_text))

基于md2html-phuker

python 复制代码
# pip install -U md2html-phuker

from md2html import md2html
html_text = md2html.convert(md_text)
display(HTML(html_text))
相关推荐
喝凉白开都长肉的大胖子17 分钟前
在 Matplotlib 中fontweight一般怎么设置
python·matplotlib
HAPPY酷1 小时前
Python高级架构师之路——从原理到实战
java·python·算法
Thomas.Sir2 小时前
第十三章:RAG知识库开发之【GraphRAG 从基础到实战】
python·ai·rag·graphrag
一个处女座的程序猿O(∩_∩)O2 小时前
Python基础知识大全:从零开始掌握Python核心语法
开发语言·python
小陈工2 小时前
Python Web开发入门(十一):RESTful API设计原则与最佳实践——让你的API既优雅又好用
开发语言·前端·人工智能·后端·python·安全·restful
deephub3 小时前
ADK 多智能体编排:SequentialAgent、ParallelAgent 与 LoopAgent 解析
人工智能·python·大语言模型·agent
FL16238631293 小时前
基于yolov26+pyqt5的混凝土墙面缺陷检测系统python源码+pytorch模型+评估指标曲线+精美GUI界面
python·qt·yolo
cxr8284 小时前
GPU 加速声场求解器 CUDA Kernel 实现细节 —— 高频超声传播仿真并行计算引擎
人工智能·python·目标跟踪
枫叶林FYL4 小时前
第10章 符号推理与神经符号AI
pytorch·python·深度学习
nimadan125 小时前
剧本杀app2025推荐,多类型剧本体验与社交互动优势
人工智能·python