Fix remove_empty_p regexp to work with nested <br> tags and whitespace.

This commit is contained in:
Jim Miller 2025-05-12 17:02:51 -05:00
parent d2f69eb5d5
commit 74de62385f
3 changed files with 3 additions and 3 deletions

View file

@ -323,7 +323,7 @@ conditionals_use_lists:true
## they aren't intended by the author during document upload and not
## all authors know how/take the time to fix it. This feature removes
## all "empty" <p> tags, ie, those containing only whitespace or <br>
## tags. Literally: <p[^>]*>\s*(<br/>)*\s*</p>
## tags.
#remove_empty_p: false
## If you have the Generate Cover plugin installed, you can use the

View file

@ -880,7 +880,7 @@ class BaseSiteAdapter(Requestable):
# Remove <p> tags that contain only whitespace and/or <br>
# tags. Generally for AO3/OTW because their document
# converter tends to add them where not intended.
retval = re.sub(r"<p[^>]*>\s*(<br/>)*\s*</p>","",retval)
retval = re.sub(r"<p[^>]*>\s*(\s*<br ?/?>\s*)*\s*</p>","",retval)
return retval

View file

@ -369,7 +369,7 @@ conditionals_use_lists:true
## they aren't intended by the author during document upload and not
## all authors know how/take the time to fix it. This feature removes
## all "empty" <p> tags, ie, those containing only whitespace or <br>
## tags. Literally: <p[^>]*>\s*(<br/>)*\s*</p>
## tags.
#remove_empty_p: false
## If set false, the summary will have all html stripped.