mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-04-24 23:56:21 +02:00
firx print_toc
This commit is contained in:
parent
7f0806a871
commit
d4c910ad5a
2 changed files with 4 additions and 4 deletions
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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'):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue