wip: (fix) module titles (remove empty lines, create divs if contents after title)

This commit is contained in:
Cyrille L 2022-12-30 17:54:44 +01:00
parent b72a1133f6
commit 757e387d84
1 changed files with 16 additions and 6 deletions

View File

@ -500,22 +500,32 @@ def wip_titles():
# Add div after title if needed
for ln, line in enumerate(article_tmp2.rsplit('\n')):
if line.startswith('<h'):
try: article_tmp2.rsplit('\n')[ln + 1]
except: continue
if article_tmp2.rsplit('\n')[ln + 1].startswith('<h'):
continue
else:
article_temp = article_temp.replace(
line, '%s\n<div class="content_title">'%line
)
continue
else:
continue
# Close div before title if needed
article_tmp2 = article_temp
# Add div after title if needed
indiv = False
for ln, line in enumerate(article_tmp2.rsplit('\n')):
if line.startswith('<h') and \
article_tmp2.rsplit('\n')[ln + 1].startswith('<div'):
indiv = True
elif line.startswith('<h') and indiv:
if line.startswith('<h'):
try: article_tmp2.rsplit('\n')[ln + 1]
except: continue
if article_tmp2.rsplit('\n')[ln + 1].startswith('<div'):
indiv = True
continue
if line.startswith('<h') and indiv:
article_temp = article_temp.replace(
line, '</div>\n%s'%line
)