MCPcopy
hub / github.com/chinesehuazhou/python-weekly / read_md

Function read_md

resources/weekly_workflow.py:199–211  ·  view source on GitHub ↗

读取并解析markdown文件,返回内容二级标题及其子标题 :param file_path: markdown文件路径 :return: 字典,key为二级标题,value为其下的子标题列表 注:只返回包含子标题的部分

(file_path)

Source from the content-addressed store, hash-verified

197 f2.write(new_content2)
198
199def read_md(file_path):
200 """
201 读取并解析markdown文件,返回内容二级标题及其子标题
202 :param file_path: markdown文件路径
203 :return: 字典,key为二级标题,value为其下的子标题列表
204 注:只返回包含子标题的部分
205 """
206 with open(file_path, 'r', encoding="utf-8") as f:
207 file_content = f.read()
208 origin_content = parse_md(file_content)
209 # 过滤掉没有子标题的部分
210 new_content = {key: value for key, value in origin_content.items() if value}
211 return new_content
212
213def parse_md(file_content):
214 """

Callers 3

write_to_md_file_enFunction · 0.70
set_content_bodyFunction · 0.70
process_weeklyFunction · 0.70

Calls 1

parse_mdFunction · 0.70

Tested by

no test coverage detected