wip: (fix) module titles (remove empty lines, create divs if contents after title)
This commit is contained in:
parent
b72a1133f6
commit
757e387d84
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue