This commit is contained in:
2025-12-16 00:00:58 +01:00
parent 647a8d1c7b
commit 5862a69ac2
4 changed files with 112 additions and 35 deletions

View File

@@ -456,6 +456,30 @@ def main():
# Clear old figure/table index entries (they need to be regenerated in Word)
print("Clearing old index entries...")
# Remove ALL content from MsoTof paragraphs that reference template examples
# The indices will be regenerated when user opens in Word and presses Ctrl+A, F9
for p in soup.find_all('p', class_='MsoTof'):
text = p.get_text()
# Check for figure index entries with template examples
if 'Figura' in text and 'Ejemplo' in text:
# Remove all <a> tags (the actual index entry links)
for a in p.find_all('a'):
a.decompose()
# Also remove any remaining text content that shows the example
for span in p.find_all('span', style=lambda x: x and 'mso-no-proof' in str(x)):
if 'Ejemplo' in span.get_text():
span.decompose()
print(" ✓ Cleared figure index example entry")
# Check for table index entries with template examples
if 'Tabla' in text and 'Ejemplo' in text:
for a in p.find_all('a'):
a.decompose()
for span in p.find_all('span', style=lambda x: x and 'mso-no-proof' in str(x)):
if 'Ejemplo' in span.get_text():
span.decompose()
print(" ✓ Cleared table index example entry")
# Remove old figure index entries that reference template examples
for p in soup.find_all('p', class_='MsoToc3'):
text = p.get_text()