From fa06f9c84ad92cd1c7f79e729f5716a6d624439c Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Thu, 29 Dec 2022 12:57:02 +0100 Subject: [PATCH] check: not paired symbols in content (warning, not error) --- src/var/lib/tyto/program/check.py | 12 +++++++++++- src/var/lib/tyto/program/tyto.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index b472dd1..c8c07ac 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -528,7 +528,6 @@ def check_content(post_bottom): # Check for all match _TAGS:NAME from content in header #------------------------------------------------------ - print(article_header) for ln, line in enumerate(post_bottom): for tag in tyto.content_tags: htag = tag[1: len(tag)] @@ -547,6 +546,17 @@ def check_content(post_bottom): if not match: 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 ! # diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index bddd878..ae5fe81 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -128,6 +128,16 @@ words_tags = [ ('-(', '-)', '-(', '-)', 'lists', 't') ] + +# warning Tags (Check paired symbols) +#-------------------------------------- +tpl_tags = [ +('(', ')'), +('[', ']'), +('{', '}') +] + + # Tags that do not need to be paired #----------------------------------- single_tags = [ @@ -454,7 +464,8 @@ def exiting(nbr, value, out): '9' : ':D Article has changed (wip is old)', '10' : ':< \033[1;31mUnused "%s"\033[0;0m in article\'s header'%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...' }