New code cleaned. Indev: wip. Some converting done

This commit is contained in:
Cyrille L 2022-12-18 14:56:36 +01:00
parent 38e977ec1d
commit fc1c059fda
1 changed files with 13 additions and 5 deletions

View File

@ -214,17 +214,21 @@ def wip_images():
image_link = '<a class="%s" href="%s" title="%s">%s</a>'
image_show = '<img class="%s" src="%s" alt="%s"%s />'
# Check each line
for ln, line in enumerate(article_bottom.rsplit('\n')):
# match line
if line.startswith('_image:'):
values = line.rsplit(' ')
#print(values)
# search match tag in DB
for i in range(1, uniq_images + 1):
image = 'image_%s'%i
target = width = height = False
set_css = tyto.domain_css + '_image'
imag_html = ''
if eval(image)[0] == values[0]:
# Get parameters from match line
for value in values:
if 't=' in value:
target = value.rsplit('=',1)[1]
@ -249,10 +253,12 @@ def wip_images():
else:
style = ''
# set <img /> from parameter
image_src = image_show%(
set_css, eval(image)[1], eval(image)[2], style
)
# Set link for image
if target:
image_tgt = image_link%(
set_css, image_target, eval(image)[2], '%s'
@ -260,8 +266,10 @@ def wip_images():
else:
image_tgt = '%s'
# Set HTML to replace line number
image_html = image_tgt%image_src
article_bottom = article_bottom.replace(
article_bottom.rsplit('\n')[ln], image_html
)