check: add inline-code check for markers in same line

This commit is contained in:
Cyrille L 2022-12-29 23:22:42 +01:00
parent b2f0df2fe4
commit 45c915e421
1 changed files with 33 additions and 2 deletions

View File

@ -57,6 +57,8 @@ def manage_check(target, option):
# Start processes
file_to_string(tyto.uri_root)
# Specific to inline-code: check markers on same line
check_icodes(article.rsplit('\n'))
# Protect inline-codes
tyto.protect_icodes(post_bottom, article_bottom)
post_bottom = tyto.protect_article.rsplit('\n')
@ -118,6 +120,37 @@ def file_to_string(post_file):
post_bottom = article.rsplit('-----')[1].rsplit('\n')
#
# Check inline code, for markers on same line
#
def check_icodes(article):
quote = bcode = False
for ln, line in enumerate(article, 1):
icode_m1 = icode_m2 = 0
# Pass Comments
if line.startswith('#'): continue
# Pass quotes
if line.startswith(tyto.words_tags[11][0]): quote = True
if line.startswith(tyto.words_tags[11][1]): quote = False
# Pass bcode
if line.startswith(tyto.words_tags[12][0]): bcode = True
if line.startswith(tyto.words_tags[12][1]): bcode = False
if bcode or quote: continue
if tyto.words_tags[9][0] or tyto.words_tags[9][1] in line:
icode_m1 = line.count(tyto.words_tags[9][0])
icode_m2 = line.count(tyto.words_tags[9][1])
if icode_m1 != icode_m2:
tyto.exiting("8", 'inline-code: line %s. %s %s'%(ln,
tyto.words_tags[9][0], tyto.words_tags[9][1]
), True
)
#==================================#
# Check tags from article's header #
#----------------------------------#
@ -127,8 +160,6 @@ def check_headers(post_header):
global stat_links, stat_images, stat_files, stat_bruts, stat_abbrs
global post_tags
#post_tags = 0
# Needed Tags
title = author = tags = about = ''
date = ()