Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -156,17 +156,13 @@ async def convert_to_accessible_html(input_filename, ext, base_filename, image_c
|
|
156 |
with open(input_filename, 'r', encoding='utf-8') as f:
|
157 |
html_content = f.read()
|
158 |
try:
|
159 |
-
# Utiliser readability-lxml pour extraire le contenu principal
|
160 |
doc = Document(html_content)
|
161 |
main_html = doc.summary() # Extrait le HTML principal
|
162 |
-
main_text = doc.
|
163 |
-
|
164 |
-
# Reconstruire le HTML avec le texte principal
|
165 |
html_content = f"<html><body><p>{main_text}</p></body></html>"
|
166 |
logging.debug("Contenu HTML nettoyé avec readability-lxml.")
|
167 |
except Exception as e:
|
168 |
logging.error(f"Erreur lors du nettoyage avec readability-lxml : {str(e)}")
|
169 |
-
# Vous pouvez décider de continuer avec le contenu HTML original ou arrêter le traitement
|
170 |
return None # Ou continuez avec html_content non modifié
|
171 |
# Conversion from PDF to HTML with PyMuPDF
|
172 |
elif ext == '.pdf':
|
|
|
156 |
with open(input_filename, 'r', encoding='utf-8') as f:
|
157 |
html_content = f.read()
|
158 |
try:
|
|
|
159 |
doc = Document(html_content)
|
160 |
main_html = doc.summary() # Extrait le HTML principal
|
161 |
+
main_text = doc.content() # Extrait le contenu texte complet
|
|
|
|
|
162 |
html_content = f"<html><body><p>{main_text}</p></body></html>"
|
163 |
logging.debug("Contenu HTML nettoyé avec readability-lxml.")
|
164 |
except Exception as e:
|
165 |
logging.error(f"Erreur lors du nettoyage avec readability-lxml : {str(e)}")
|
|
|
166 |
return None # Ou continuez avec html_content non modifié
|
167 |
# Conversion from PDF to HTML with PyMuPDF
|
168 |
elif ext == '.pdf':
|