firx print_toc

This commit is contained in:
zmtomorrow 2025-08-31 11:51:50 +01:00
parent 7f0806a871
commit d4c910ad5a
2 changed files with 4 additions and 4 deletions

View file

@ -302,9 +302,8 @@ if __name__ == "__main__":
import json import json
# MD_NAME = 'Detect-Order-Construct' # MD_NAME = 'Detect-Order-Construct'
MD_NAME = 'mcp' MD_NAME = 'cognitive-load'
# MD_NAME = 'Welcome' MD_PATH = os.path.join(os.path.dirname(__file__), '..', 'tests/markdowns/', f'{MD_NAME}.md')
MD_PATH = os.path.join(os.path.dirname(__file__), '..', 'docs', f'{MD_NAME}.md')
MODEL="gpt-4.1" MODEL="gpt-4.1"
@ -329,7 +328,7 @@ if __name__ == "__main__":
print('\n' + '='*60) print('\n' + '='*60)
print('TABLE OF CONTENTS') print('TABLE OF CONTENTS')
print('='*60) print('='*60)
print_toc(tree_structure) print_toc(tree_structure['structure'])
output_path = os.path.join(os.path.dirname(__file__), '..', 'results', f'{MD_NAME}_structure.json') output_path = os.path.join(os.path.dirname(__file__), '..', 'results', f'{MD_NAME}_structure.json')
os.makedirs(os.path.dirname(output_path), exist_ok=True) os.makedirs(os.path.dirname(output_path), exist_ok=True)

View file

@ -499,6 +499,7 @@ def remove_fields(data, fields=['text']):
return data return data
def print_toc(tree, indent=0): def print_toc(tree, indent=0):
print(tree)
for node in tree: for node in tree:
print(' ' * indent + node['title']) print(' ' * indent + node['title'])
if node.get('nodes'): if node.get('nodes'):