some fixes

This commit is contained in:
Cyrille L 2023-01-18 00:38:56 +01:00
parent 8b00709200
commit a71e2e58e6
2 changed files with 20 additions and 20 deletions

View File

@ -459,12 +459,14 @@ def check_headers(post_header):
) )
# snpic (set image to share to social networks) # snpic (set image to share to social networks)
#----------------------------------------------
if snpic_name: continue if snpic_name: continue
tag = tyto.headers[11] # snpic: tag = tyto.headers[11] # snpic:
if line.startswith(tag): if line.startswith(tag):
snpic_name = post_header[ln - 1].rsplit(tag)[1].lstrip() snpic_name = post_header[ln - 1].rsplit(tag)[1].lstrip()
for ln, line in enumerate(post_header, 1): for ln, line in enumerate(post_header, 1):
if re.search(r"^image:\s+hello$", line): if re.search(r"^image:\s+%s$"%snpic_name, line):
image_uri = post_header[ln].lstrip() image_uri = post_header[ln].lstrip()
check_file_uri('image', image_uri, ln + 1) check_file_uri('image', image_uri, ln + 1)
snshare = True snshare = True
@ -472,7 +474,7 @@ def check_headers(post_header):
break break
if not snshare: if not snshare:
tyto.exiting("10", '%s %s'%(tyto.headers[6], snpic_name), True) tyto.exiting("10", '%s %s'%(tyto.headers[6], snpic_name), True)
# Exit if error in optional tags # Exit if error in optional tags
#------------------------------- #-------------------------------
if post_err: if post_err:
@ -519,7 +521,7 @@ def check_file_uri(filetype, filename, ln):
fileuri = domain_files + filename[1: len(filename)] fileuri = domain_files + filename[1: len(filename)]
elif filename.startswith('/'): elif filename.startswith('/'):
fileuri = domain_articles + filename[1: len(filename)] fileuri = tyto.post_dir + filename[1: len(filename)]
else: else:
fileuri = tyto.post_dir + filename fileuri = tyto.post_dir + filename
@ -604,23 +606,22 @@ def check_content(post_bottom):
# Check for all match _TAGS:NAME from content in header # Check for all match _TAGS:NAME from content in header
#------------------------------------------------------ #------------------------------------------------------
set_tags = ()
for ln, line in enumerate(post_bottom): for ln, line in enumerate(post_bottom):
for tag in tyto.content_tags: for htag in tyto.head_tags:
htag = tag[1: len(tag)] match = False
ptag = '_%s'%htag
if line.startswith(tag): if line.startswith(ptag):
tag_id = line.rsplit(':', 1)[1].rsplit(' ')[0] ptag_set = line.rsplit(':', 1)[1].lstrip() # Get set tag
if ptag_set in set_tags: continue
match = False
for hline in post_header: for hline in post_header:
if hline.startswith(htag): if re.search(r"^%s\s+%s$"%(htag,ptag_set), hline):
htag_id = hline.rsplit(':', 1)[1].lstrip() match = True
if htag_id == tag_id: set_tags = (ptag_set)
match = True
break if match: continue
else: tyto.exiting("10", "%s %s"%(htag, ptag_set), True)
if not match:
tyto.exiting("10", "%s %s"%(htag, tag_id), True)
# Template Tags (warning for not paired symbols) # Template Tags (warning for not paired symbols)

View File

@ -178,9 +178,8 @@ quote_tags = [
('_lang:', 'lang') ('_lang:', 'lang')
] ]
# Tags to check for header in content # Tags to check in header in content _TAG
content_tags = ("_image:", '_raw:') head_tags = ("image:", "raw:")
#=======# #=======#
# TOOLS # # TOOLS #