diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 1171226..70a5747 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -287,7 +287,7 @@ def protect_icodes(post_bottom, article_bottom): if c_a == '}' and not c_b == '\\': incode = False code = '%s%s%s'%(code, src_code, words_tags[9][3]) - b64_code = b64('Encode', code) + b64_code = b64('Encode', code, 'I64_', '_I64') rep_code = "%s%s%s"%( words_tags[9][0],rep_code,words_tags[9][1] ) @@ -364,7 +364,7 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom): elif line.startswith(words_tags[12][1]): bcode = '%s\n%s'%(bcode, line) in_bcode = False - b64_bcode = b64('Encode', bcode) + b64_bcode = b64('Encode', bcode, 'B64_', '_B64') protect_article = '%s\n%s'%(protect_article, b64_bcode) bcode = '' continue @@ -380,7 +380,7 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom): if not in_bcode: quote = '%s\n%s'%(quote, line) in_quote = False - b64_quote = b64('Encode', quote) + b64_quote = b64('Encode', quote, 'Q64_', '_Q64') protect_article = '%s\n%s'%(protect_article, b64_quote) quote = '' continue @@ -402,19 +402,19 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom): # Encode/Decode string to/from base64 # # Data protection # #-------------------------------------# -def b64(action, content): +def b64(action, content, before, after): if action == 'Encode': global b64_content b64_base64 = '' content_bytes = content.encode("ascii") base64_bytes = base64.b64encode(content_bytes) - b64_content = 'B64_' + base64_bytes.decode("ascii") + '_B64' + b64_content = before + base64_bytes.decode("ascii") + after return b64_content elif action == 'Decode': global src_content src_content = '' - content_bytes = post_content.encode("ascii") + content_bytes = content.encode("ascii") base64_bytes = base64.b64decode(content_bytes) src_content = base64_bytes.decode("ascii") return src_content diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index f9e4fb2..fec5fcb 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -86,6 +86,9 @@ def wip_article(target): wip_words_tags() # Paragraphs, strongs, italics wip_links() # Links_%i from headers in DB wip_images() # Images_%i from headers in DB + + # Quotes + wip_quotes() # Decode B64 and convert print(article_bottom) @@ -273,3 +276,19 @@ def wip_images(): article_bottom.rsplit('\n')[ln], image_html ) + +# +# INDEV: convert quote in article +# +def wip_quotes() : + global article_bottom + + for ln, line in enumerate(article_bottom.rsplit('\n')): + if line.startswith('Q64'): + line = line.replace('Q64_', '') + line = line.replace('_Q64', '') + quote = tyto.b64('Decode', line, 'Q64_', '_Q64').rsplit("\n") + + # Read the quote + for qline in quote: + print('>', qline)