wip: images ; split from regex var

This commit is contained in:
Cyrille L 2022-11-21 14:18:15 +01:00
parent bd2e7a7138
commit cc039f4555
1 changed files with 8 additions and 6 deletions

View File

@ -444,7 +444,7 @@ def quote_data(line):
#=========================# #=========================#
# Convert files_links # # Convert files_links #
# from header "file: xxx" # # # from header "file: xxx" #
#-------------------------# #-------------------------#
def wip_files_links(article): def wip_files_links(article):
global wip_html global wip_html
@ -469,11 +469,12 @@ def wip_files_links(article):
#==========================# #==========================#
# Convert images # # Convert images #
# from header "image: xxx" # # from header "image: xxx" #
# Get parameters from line # # # Get parameters from line #
#--------------------------# #--------------------------#
def wip_images(article): def wip_images(article):
global wip_html global wip_html
regex_dw = r"([0-9]+)([a-z]+)"
wip_html = '' wip_html = ''
image_fmt = '<img class="%s" title="%s" alt="%s" %ssrc="%s" />' image_fmt = '<img class="%s" title="%s" alt="%s" %ssrc="%s" />'
img_style = '%s' # %(wh_style) style="..." if width and/or height img_style = '%s' # %(wh_style) style="..." if width and/or height
@ -509,7 +510,7 @@ def wip_images(article):
elif width.isdigit(): elif width.isdigit():
width = 'width:%spx;'%width width = 'width:%spx;'%width
else: else:
wspl = re.match(r"([0-9]+)([a-z]+)",width,re.I).groups() wspl = re.match(regex_dw, width, re.I).groups()
width = 'width:%s;'%width width = 'width:%s;'%width
# Height # Height
@ -519,7 +520,7 @@ def wip_images(article):
elif height.isdigit(): elif height.isdigit():
height = 'height:%spx;'%height height = 'height:%spx;'%height
else: else:
hspl = re.match(r"([0-9]+)([a-z]+)",height,re.I).groups() hspl = re.match(regex_dw, height, re.I).groups()
height = 'height:%s;'%height height = 'height:%s;'%height
# Target # Target
@ -542,11 +543,12 @@ def wip_images(article):
# Create Target link if t= # Create Target link if t=
if target: if target:
line = '<a class="%s" href="%s">%s</a>'%( line = '<a class="%s" href="%s">%s</a>'%(
set_css, target, image_html) set_css, target, image_html
)
else: else:
line = image_html line = image_html
# Replace line
if wip_html: wip_html = '%s\n%s'%(wip_html, line) if wip_html: wip_html = '%s\n%s'%(wip_html, line)
else : wip_html = line else : wip_html = line