auto_cleanup = True in recipe.
https://manual.calibre-ebook.com/new...Recipe.cleanup
you can use
keep_only_tags & remove_tags to keep only those html tags you think has text and images and remove unnecessary tags to fix it.
https://manual.calibre-ebook.com/new...keep_only_tags