wip: images
This commit is contained in:
parent
a3ab6c62b0
commit
bd2e7a7138
|
@ -597,7 +597,7 @@ def check_files(line, ln, stats_files_uniq):
|
|||
log.append_f(post_logs,msg_log,1)
|
||||
Post_Err = True
|
||||
else:
|
||||
file_uri = '/%s'%(file_uri)
|
||||
file_uri = '/%s'%file_uri
|
||||
|
||||
# Current or custom URI
|
||||
else:
|
||||
|
@ -632,7 +632,7 @@ def check_images(line, ln, stats_images_uniq):
|
|||
|
||||
# Create variable array
|
||||
image_nbr = 'image_%s'%stats_images_uniq
|
||||
image_name = line.split('image:')[1].lstrip()
|
||||
image_name = line.split('image:')[1].lstrip().rsplit(' ')[0]
|
||||
image_uri = headers.rsplit('\n')[ln].lstrip()
|
||||
image_alt = headers.rsplit('\n')[ln+1].lstrip()
|
||||
|
||||
|
@ -657,7 +657,7 @@ def check_images(line, ln, stats_images_uniq):
|
|||
|
||||
# Check value in article
|
||||
image_page = '_image:%s'%image_name
|
||||
if not image_page in article.rsplit('\n'):
|
||||
if not image_page in article:
|
||||
msg_log = 'Unused "%s" for marker "image:" in article"'%image_page
|
||||
log.append_f(post_logs, msg_log, 1)
|
||||
Post_Err = True
|
||||
|
@ -683,7 +683,7 @@ def check_images(line, ln, stats_images_uniq):
|
|||
log.append_f(post_logs, msg_log, 1)
|
||||
Post_Err = True
|
||||
else:
|
||||
image_uri = '/%s'%(image_uri)
|
||||
image_uri = '/%s'%image_uri
|
||||
|
||||
# Current or custom URI
|
||||
else:
|
||||
|
|
|
@ -94,7 +94,9 @@ def manage_wip(file_post, Force):
|
|||
wip_begin_markers(wip_html.rsplit('\n'))
|
||||
wip_titles( wip_html.rsplit('\n'))
|
||||
wip_words_markers(wip_html)
|
||||
wip_files_links(wip_html)
|
||||
|
||||
if files_u > 0: wip_files_links(wip_html)
|
||||
if images_u > 0: wip_images( wip_html)
|
||||
if anchors > 0: wip_anchors( wip_html)
|
||||
if abbrs_u > 0: wip_abbrs( wip_html)
|
||||
|
||||
|
@ -108,8 +110,8 @@ def manage_wip(file_post, Force):
|
|||
print('> Article HTML:')
|
||||
print(wip_html)
|
||||
|
||||
print('> Article with Tabs:')
|
||||
tab_article(wip_html.rsplit('\n'))
|
||||
#print('> Article with Tabs:')
|
||||
#tab_article(wip_html.rsplit('\n'))
|
||||
|
||||
|
||||
|
||||
|
@ -440,9 +442,10 @@ def quote_data(line):
|
|||
return line.split(' ', 1)[1].lstrip()
|
||||
|
||||
|
||||
#
|
||||
# Convert files_links
|
||||
#
|
||||
#=========================#
|
||||
# Convert files_links #
|
||||
# from header "file: xxx" # #
|
||||
#-------------------------#
|
||||
def wip_files_links(article):
|
||||
global wip_html
|
||||
|
||||
|
@ -463,6 +466,91 @@ def wip_files_links(article):
|
|||
wip_html = article
|
||||
|
||||
|
||||
#==========================#
|
||||
# Convert images #
|
||||
# from header "image: xxx" #
|
||||
# Get parameters from line # #
|
||||
#--------------------------#
|
||||
def wip_images(article):
|
||||
global wip_html
|
||||
|
||||
wip_html = ''
|
||||
image_fmt = '<img class="%s" title="%s" alt="%s" %ssrc="%s" />'
|
||||
img_style = '%s' # %(wh_style) style="..." if width and/or height
|
||||
|
||||
all_vars = set(globals())
|
||||
|
||||
for var in all_vars:
|
||||
if var.startswith('image_'):
|
||||
image = globals()[var]
|
||||
|
||||
# Search in article lines for _image:
|
||||
for line in article.rsplit('\n'):
|
||||
if not line.startswith('_image:'):
|
||||
if wip_html: wip_html = '%s\n%s'%(wip_html, line)
|
||||
else : wip_html = line
|
||||
|
||||
elif line.startswith('_image:%s'%image[0]):
|
||||
width = height = set_css = target = ''
|
||||
image_html = ''
|
||||
wh_style = '' # width and/or height parameters
|
||||
|
||||
# Get parameters and set values for this marker
|
||||
image_params = (line.rsplit(' '))
|
||||
for param in image_params:
|
||||
# CSS
|
||||
if param.startswith('c='):
|
||||
set_css = param.rsplit('=')[1]
|
||||
|
||||
# Width
|
||||
elif param.startswith('w='):
|
||||
width = param.rsplit('=')[1]
|
||||
if not width: width = ''
|
||||
elif width.isdigit():
|
||||
width = 'width:%spx;'%width
|
||||
else:
|
||||
wspl = re.match(r"([0-9]+)([a-z]+)",width,re.I).groups()
|
||||
width = 'width:%s;'%width
|
||||
|
||||
# Height
|
||||
elif param.startswith('h='):
|
||||
height = param.rsplit('=')[1]
|
||||
if not height: height = ''
|
||||
elif height.isdigit():
|
||||
height = 'height:%spx;'%height
|
||||
else:
|
||||
hspl = re.match(r"([0-9]+)([a-z]+)",height,re.I).groups()
|
||||
height = 'height:%s;'%height
|
||||
|
||||
# Target
|
||||
elif param.startswith('t='):
|
||||
target = param.rsplit('=')[1]
|
||||
if not target: target = image[1]
|
||||
|
||||
# Check values and construct HTML
|
||||
if not set_css: set_css = domain.domain_css
|
||||
if width and height: wh_style = 'style="%s%s" '%(width,height)
|
||||
elif width : wh_style = 'style="%s" '%width
|
||||
elif height : wh_style = 'style="%s" '%height
|
||||
|
||||
image_html = image_fmt%(set_css,
|
||||
image[2], image[2],
|
||||
img_style%wh_style,
|
||||
image[1]
|
||||
)
|
||||
|
||||
# Create Target link if t=
|
||||
if target:
|
||||
line = '<a class="%s" href="%s">%s</a>'%(
|
||||
set_css, target, image_html)
|
||||
|
||||
else:
|
||||
line = image_html
|
||||
|
||||
if wip_html: wip_html = '%s\n%s'%(wip_html, line)
|
||||
else : wip_html = line
|
||||
|
||||
|
||||
#=========================#
|
||||
# Done when command check #
|
||||
# - convert_bcodes() #
|
||||
|
|
Loading…
Reference in New Issue