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
|
# Add div after title if needed
|
||||||
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
||||||
if line.startswith('<h'):
|
if line.startswith('<h'):
|
||||||
|
try: article_tmp2.rsplit('\n')[ln + 1]
|
||||||
|
except: continue
|
||||||
|
|
||||||
if article_tmp2.rsplit('\n')[ln + 1].startswith('<h'):
|
if article_tmp2.rsplit('\n')[ln + 1].startswith('<h'):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
article_temp = article_temp.replace(
|
article_temp = article_temp.replace(
|
||||||
line, '%s\n<div class="content_title">'%line
|
line, '%s\n<div class="content_title">'%line
|
||||||
)
|
)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Close div before title if needed
|
||||||
article_tmp2 = article_temp
|
article_tmp2 = article_temp
|
||||||
# Add div after title if needed
|
|
||||||
indiv = False
|
indiv = False
|
||||||
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
||||||
if line.startswith('<h') and \
|
if line.startswith('<h'):
|
||||||
article_tmp2.rsplit('\n')[ln + 1].startswith('<div'):
|
try: article_tmp2.rsplit('\n')[ln + 1]
|
||||||
indiv = True
|
except: continue
|
||||||
|
|
||||||
elif line.startswith('<h') and indiv:
|
if article_tmp2.rsplit('\n')[ln + 1].startswith('<div'):
|
||||||
|
indiv = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.startswith('<h') and indiv:
|
||||||
article_temp = article_temp.replace(
|
article_temp = article_temp.replace(
|
||||||
line, '</div>\n%s'%line
|
line, '</div>\n%s'%line
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue