check: not paired symbols in content (warning, not error)

This commit is contained in:
Cyrille L 2022-12-29 12:57:02 +01:00
parent 3b52377ce7
commit fa06f9c84a
2 changed files with 23 additions and 2 deletions

View File

@ -528,7 +528,6 @@ 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
#------------------------------------------------------ #------------------------------------------------------
print(article_header)
for ln, line in enumerate(post_bottom): for ln, line in enumerate(post_bottom):
for tag in tyto.content_tags: for tag in tyto.content_tags:
htag = tag[1: len(tag)] htag = tag[1: len(tag)]
@ -548,6 +547,17 @@ def check_content(post_bottom):
tyto.exiting("10", "%s %s"%(htag, tag_id), True) tyto.exiting("10", "%s %s"%(htag, tag_id), True)
# Template Tags (warning for not paired symbols)
#-----------------------------------------------
for tag in tyto.tpl_tags:
tpl1 = article_bottom.count(tag[0])
tpl2 = article_bottom.count(tag[1])
if tpl1 != tpl2:
tyto.exiting("22", '"%s", "%s"'%(tag[0], tag[1]), False)
#===============================================# #===============================================#
# Create new article's database at each check ! # # Create new article's database at each check ! #
#-----------------------------------------------# #-----------------------------------------------#

View File

@ -128,6 +128,16 @@ words_tags = [
('-(', '-)', '-(', '-)', 'lists', 't') ('-(', '-)', '-(', '-)', 'lists', 't')
] ]
# warning Tags (Check paired symbols)
#--------------------------------------
tpl_tags = [
('(', ')'),
('[', ']'),
('{', '}')
]
# Tags that do not need to be paired # Tags that do not need to be paired
#----------------------------------- #-----------------------------------
single_tags = [ single_tags = [
@ -454,7 +464,8 @@ def exiting(nbr, value, out):
'9' : ':D Article has changed (wip is old)', '9' : ':D Article has changed (wip is old)',
'10' : ':< \033[1;31mUnused "%s"\033[0;0m in article\'s header'%value, '10' : ':< \033[1;31mUnused "%s"\033[0;0m in article\'s header'%value,
'20' : ':D Article already up-to-date on: %s'%value, '20' : ':D Article already up-to-date on: %s'%value,
'21' : ':D Article is valid and ready to wip', '21' : ':D \033[1;32mArticle is valid\033[0;0m and ready to wip',
'22' : ':/ \033[1;33mWarning: not paired symbols\033[0;0m %s'%value,
'255' : ':| Maybe later...' '255' : ':| Maybe later...'
} }