From cc039f4555e388e77dc60b2d11ddf7d1e0c32a64 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Mon, 21 Nov 2022 14:18:15 +0100 Subject: [PATCH] wip: images ; split from regex var --- src/var/lib/tyto/program/wip.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 9c82352..729864f 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -444,7 +444,7 @@ def quote_data(line): #=========================# # Convert files_links # -# from header "file: xxx" # # +# from header "file: xxx" # #-------------------------# def wip_files_links(article): global wip_html @@ -469,11 +469,12 @@ def wip_files_links(article): #==========================# # Convert images # # from header "image: xxx" # -# Get parameters from line # # +# Get parameters from line # #--------------------------# def wip_images(article): global wip_html + regex_dw = r"([0-9]+)([a-z]+)" wip_html = '' image_fmt = '%s' img_style = '%s' # %(wh_style) style="..." if width and/or height @@ -509,7 +510,7 @@ def wip_images(article): elif width.isdigit(): width = 'width:%spx;'%width 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 # Height @@ -519,7 +520,7 @@ def wip_images(article): elif height.isdigit(): height = 'height:%spx;'%height 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 # Target @@ -542,11 +543,12 @@ def wip_images(article): # Create Target link if t= if target: line = '%s'%( - set_css, target, image_html) - + set_css, target, image_html + ) else: line = image_html + # Replace line if wip_html: wip_html = '%s\n%s'%(wip_html, line) else : wip_html = line