2023-12-09 02:03:41 +08:00
|
|
|
|
2023-12-09 01:47:35 +08:00
|
|
|
from pathlib import Path
|
2023-12-09 02:03:41 +08:00
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
import mistune
|
|
|
|
|
|
|
|
ast_markdown = mistune.create_markdown(renderer='ast')
|
2023-12-09 01:47:35 +08:00
|
|
|
|
|
|
|
def read_files(module_path: Path):
|
2023-12-09 02:03:41 +08:00
|
|
|
with open(module_path, 'r', encoding='utf-8') as f:
|
|
|
|
file = f.read()
|
|
|
|
|
|
|
|
parsed = ast_markdown(file)
|
|
|
|
return parsed
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
module_path = Path('modules')
|
|
|
|
|
|
|
|
# walk through the modules
|
|
|
|
# for every markdown file
|
|
|
|
# parse the label
|
|
|
|
|
|
|
|
for md_file in module_path.rglob('*.md'):
|
|
|
|
print(md_file)
|
|
|
|
parsed = read_files(md_file)
|
|
|
|
pprint(parsed)
|
|
|
|
|