wip: Added module block-code (InDev for more html tags, maybe)

This commit is contained in:
Cyrille L 2022-12-30 01:20:19 +01:00
parent 2d1ccc1ec8
commit ba052211ca
1 changed files with 46 additions and 3 deletions

View File

@ -87,14 +87,18 @@ def wip_article(target):
wip_links() # Links_%i from headers in DB wip_links() # Links_%i from headers in DB
wip_images() # Images_%i from headers in DB wip_images() # Images_%i from headers in DB
# Quotes # Quotes. Decode base64 Q64 and convert to HTML
wip_quotes() # Decode B64 and convert wip_quotes()
# inline_codes # inline_codes. Decode base64 icode and replace
wip_icodes() wip_icodes()
# Block-codes. Decode B64 and convert to HTML
wip_bcodes()
print(article_bottom) print(article_bottom)
#=================================# #=================================#
# Create string article from file # # Create string article from file #
# post is string splitted '\n' # # post is string splitted '\n' #
@ -421,8 +425,10 @@ def wip_quotes() :
'Q64.%s.Q64'%line, quote_html 'Q64.%s.Q64'%line, quote_html
) )
#==========================# #==========================#
# Convert all inline-codes # # Convert all inline-codes #
# Content is HTML ready #
#--------------------------# #--------------------------#
def wip_icodes(): def wip_icodes():
global article_bottom global article_bottom
@ -432,3 +438,40 @@ def wip_icodes():
rep_icode = 'I64.' + match + '.I64' rep_icode = 'I64.' + match + '.I64'
src_icode = tyto.b64("Decode", match, 'I64.', '.I64') src_icode = tyto.b64("Decode", match, 'I64.', '.I64')
article_bottom = article_bottom.replace(rep_icode, src_icode) article_bottom = article_bottom.replace(rep_icode, src_icode)
#==================================================#
# Convert all block-codes #
# Content is raw, and have to be converted in HTML #
#--------------------------------------------------#
def wip_bcodes():
global article_bottom
matches = re.findall(r'B64.(.*?).B64', article_bottom)
for match in matches:
rep_bcode = 'B64.' + match + '.B64'
src_bcode = tyto.b64("Decode", match, 'B64.', '.B64')
# Convert src_bcode
for line in src_bcode.rsplit('\n'):
# CSS + opened marker
if line.startswith(tyto.words_tags[12][0]):
set_css = tyto.get_css(line)
html_bcode = '<pre class="%s">\n'%set_css + \
' <code class="bcode">'
# closed marker
elif line.startswith(tyto.words_tags[12][1]):
html_bcode = '%s\n </code>\n'%html_bcode + \
'</pre>'
# Block-code content per line
else:
html_bcode = '%s\n <span class="bcode">%s</span>'%(html_bcode, line)
article_bottom = article_bottom.replace(rep_bcode, html_bcode)