Better HTML tabulations

This commit is contained in:
Cyrille L 2023-01-17 16:20:43 +01:00
parent 60079467f6
commit 8b00709200
1 changed files with 18 additions and 8 deletions

View File

@ -628,34 +628,44 @@ def wip_raws(target):
def wip_tabs():
global article_bottom
article_temp = ''
tab = tab_start = 2 # From <article> tag
tab = tab_start = 6 # From <article> tag
indiv = False
tabs_hX = {
'1' : '6',
'2' : '8',
'3' : '10',
'4' : '12',
'5' : '14',
'6' : '16'
}
for line in article_bottom.rsplit('\n'):
# Titles
if line.startswith('<h'):
get_tab = line[2]
tab = int(tab_start) + 2 * int(get_tab)
if not article_temp: article_temp = '%s%s'%(tab * ' ', line)
else: article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
tab = tabs_hX[get_tab]
if not article_temp: article_temp = '%s%s'%(int(tab) * ' ', line)
else: article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
continue
# div
if line.startswith('<div'):
tab = int(tab) + 2
indiv = True
article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
tab = int(tab) + 2
continue
elif line.startswith('</div>'):
tab = int(tab) - 2
article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
indiv = False
continue
# Other contents
else:
article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
if not article_temp: article_temp = '%s%s'%(int(tab) * ' ', line)
else: article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
article_bottom = article_temp