wip: fix. Protected quotes and bcodes

This commit is contained in:
Cyrille L 2023-01-03 11:38:02 +01:00
parent cee1c67739
commit 6877d67533
2 changed files with 46 additions and 46 deletions

View File

@ -381,49 +381,49 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom):
if not protect_article: protect_article = line
else: protect_article = '%s\n%s'%(protect_article, line)
# For wip, bcodes are converted to base64
#----------------------------------------
elif process == 'wip':
# Convert bcodes and quotes
# include markers in base64, remove from article
bcode = quote = ''
for ln, line in enumerate(post_bottom):
# bcode
end_bcode = end_quote = False
for line in post_bottom:
# Bcode
if not in_quote:
if line.startswith(words_tags[12][0]):
in_bcode = True
elif line.startswith(words_tags[12][1]):
bcode = '%s\n%s'%(bcode, line)
in_bcode = False
b64_bcode = b64('Encode', bcode, 'B64.', '.B64')
protect_article = '%s\n%s'%(protect_article, b64_bcode)
bcode = ''
continue
elif line.startswith('#'): # As convention
if not line.startswith(titles_tags):
continue
line = b64_bcode
end_bcode = True
in_bcode = False
# quote
elif line.startswith(words_tags[11][0]):
# Quote
if not in_bcode:
if line.startswith(words_tags[11][0]):
in_quote = True
elif line.startswith(words_tags[11][1]):
if not in_bcode:
quote = '%s\n%s'%(quote, line)
in_quote = False
b64_quote = b64('Encode', quote, 'Q64.', '.Q64')
protect_article = '%s\n%s'%(protect_article, b64_quote)
quote = ''
continue
line = b64_quote
end_quote = True
in_quote = False
# Priority to bcode
if in_bcode:
if bcode: bcode = '%s\n%s'%(bcode, line)
else: bcode = line
else:
if in_quote:
if quote: quote = '%s\n%s'%(quote, line)
else: quote = line
if not bcode: bcode = line
else: bcode = '%s\n%s'%(bcode, line)
elif in_quote:
if not quote: quote = line
else: quote = '%s\n%s'%(quote, line)
if end_bcode: bcode = ''; end_bcode = False ; in_bcode = False
elif end_quote: quote = ''; end_quote = False ; in_quote = False
if in_quote or in_bcode:
continue
else:
if not protect_article: protect_article = line
else: protect_article = '%s\n%s'%(protect_article, line)
@ -455,11 +455,11 @@ def b64(action, content, before, after):
sys.exit(1)
#
# Replace in post_db
# Used for wip and publish
# to replace hash and date when done
#
#====================================#
# Replace in post_db #
# Used for wip and publish #
# to replace hash and date when done #
#------------------------------------#
def replace_in_db(post_db, process, hash_post):
file_db = open(post_db, "r")
lines = file_db.readlines()
@ -481,7 +481,6 @@ def replace_in_db(post_db, process, hash_post):
file.close()
#================================#
# Exit from program with message #
#--------------------------------#
@ -500,7 +499,8 @@ def exiting(nbr, value, out):
'20' : ':D Article already up-to-date on: %s'%value,
'21' : ':D \033[1;32mArticle is valid\033[0;0m and ready to wip',
'22' : ':? Symbols: %s \033[1;33mnot paired\033[0;0m'%value,
'23' : ':< \033[1;33mDatabase was corrupt\033[0;0m: %s'%value,
'23' : ':? \033[1;33mDatabase was corrupt\033[0;0m: %s'%value,
'24' : ':? \033[1;33mMissing wip file\033[0;0m: %s'%value,
'255' : ':| Maybe later...'
}

View File

@ -51,7 +51,7 @@ def manage_wip(target, option):
if do_wip:
# Show message if wip was done
if hash_wip:
if not is_file: tyto.exiting("1", wip_uri, False)
if not is_file: tyto.exiting("24", wip_uri, False)
if is_new: tyto.exiting("9", '', False)
wip_article(target)
else: