LaTex ecuations
Some checks failed
build_docker / essential (push) Successful in 1s
build_docker / build_paddle_ocr (push) Has started running
build_docker / build_doctr_gpu (push) Has been cancelled
build_docker / build_easyocr (push) Has been cancelled
build_docker / build_easyocr_gpu (push) Has been cancelled
build_docker / build_doctr (push) Has been cancelled
build_docker / build_raytune (push) Has been cancelled
build_docker / build_paddle_ocr_gpu (push) Has been cancelled
Some checks failed
build_docker / essential (push) Successful in 1s
build_docker / build_paddle_ocr (push) Has started running
build_docker / build_doctr_gpu (push) Has been cancelled
build_docker / build_easyocr (push) Has been cancelled
build_docker / build_easyocr_gpu (push) Has been cancelled
build_docker / build_doctr (push) Has been cancelled
build_docker / build_raytune (push) Has been cancelled
build_docker / build_paddle_ocr_gpu (push) Has been cancelled
This commit is contained in:
@@ -404,30 +404,36 @@ def main():
|
||||
print(" ✓ Removed template table example")
|
||||
break
|
||||
|
||||
# Define chapters
|
||||
# Define chapters with their number for bookmark creation
|
||||
chapters = [
|
||||
('Introducción', 'intro', 'Contexto'),
|
||||
('Contexto', 'contexto', 'Objetivos'),
|
||||
('Objetivos', 'objetivos', 'Desarrollo'),
|
||||
('Desarrollo', 'desarrollo', 'Conclusiones'),
|
||||
('Conclusiones', 'conclusiones', 'Referencias'),
|
||||
('Introducción', 'intro', 'Contexto', 1),
|
||||
('Contexto', 'contexto', 'Objetivos', 2),
|
||||
('Objetivos', 'objetivos', 'Desarrollo', 3),
|
||||
('Desarrollo', 'desarrollo', 'Conclusiones', 4),
|
||||
('Conclusiones', 'conclusiones', 'Referencias', 5),
|
||||
]
|
||||
|
||||
print("Replacing chapter contents...")
|
||||
for chapter_keyword, doc_key, next_keyword in chapters:
|
||||
for chapter_keyword, doc_key, next_keyword, chapter_num in chapters:
|
||||
print(f" Processing: {chapter_keyword}")
|
||||
|
||||
start_elem = find_section_element(soup, chapter_keyword)
|
||||
end_elem = find_section_element(soup, next_keyword)
|
||||
|
||||
if start_elem and end_elem:
|
||||
# Add bookmark anchor for chapter cross-references (e.g., _Ref_Sec2 for Chapter 2)
|
||||
bookmark_id = f"_Ref_Sec{chapter_num}"
|
||||
bookmark_anchor = soup.new_tag('a')
|
||||
bookmark_anchor['name'] = bookmark_id
|
||||
start_elem.insert(0, bookmark_anchor)
|
||||
|
||||
remove_elements_between(start_elem, end_elem)
|
||||
new_content_html, counters = extract_section_content(docs[doc_key], counters=counters)
|
||||
new_soup = BeautifulSoup(new_content_html, 'html.parser')
|
||||
insert_point = start_elem
|
||||
for new_elem in reversed(list(new_soup.children)):
|
||||
insert_point.insert_after(new_elem)
|
||||
print(f" ✓ Replaced content")
|
||||
print(f" ✓ Replaced content (bookmark: {bookmark_id})")
|
||||
else:
|
||||
if not start_elem:
|
||||
print(f" Warning: Could not find start element for {chapter_keyword}")
|
||||
|
||||
Reference in New Issue
Block a user