You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
672 B

import markdown_to_json
import json
if __name__ == '__main__':
# 打开文本文件 Sample.md
with open("Sample.md", "r", encoding="utf-8") as file:
# 读取 Markdown 文件的内容
markdown_content = file.read()
# 将 Markdown 转换为 JSON
json_content = markdown_to_json.jsonify(markdown_content)
# 解码 Unicode 转义
json_content = json_content.encode('utf-8').decode('unicode_escape')
# 尝试将其转换为字典
json_content = json.loads(json_content)
json_str = json.dumps(json_content, ensure_ascii=False)
# 打印 JSON 内容
print(json_str)