Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Only add body tags if they don't already exist, closes #919

davidmezzettidd8ff3078a5a
diff --git a/src/python/txtai/pipeline/data/filetohtml.py b/src/python/txtai/pipeline/data/filetohtml.py
index 15505247..c50ed58f 100644
--- a/src/python/txtai/pipeline/data/filetohtml.py
+++ b/src/python/txtai/pipeline/data/filetohtml.py
@@ -196,8 +196,8 @@ class Docling:
normalized html
"""
- # Wrap content with a body tag
- html = html.replace("<head/>", "<head/><body>").replace("</html>", "</body></html>")
+ # Wrap content with a body tag, if necessary
+ html = html.replace("<head/>", "<head/><body>").replace("</html>", "</body></html>") if "<body>" not in html else html
# Remove bullets from list items
html = re.sub(r"<li>\xb7 ", r"<li>", html)