diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index f979dec..0c84e67 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -87,14 +87,18 @@ def wip_article(target): wip_links() # Links_%i from headers in DB wip_images() # Images_%i from headers in DB - # Quotes - wip_quotes() # Decode B64 and convert + # Quotes. Decode base64 Q64 and convert to HTML + wip_quotes() - # inline_codes + # inline_codes. Decode base64 icode and replace wip_icodes() + + # Block-codes. Decode B64 and convert to HTML + wip_bcodes() print(article_bottom) + #=================================# # Create string article from file # # post is string splitted '\n' # @@ -421,8 +425,10 @@ def wip_quotes() : 'Q64.%s.Q64'%line, quote_html ) + #==========================# # Convert all inline-codes # +# Content is HTML ready # #--------------------------# def wip_icodes(): global article_bottom @@ -432,3 +438,40 @@ def wip_icodes(): rep_icode = 'I64.' + match + '.I64' src_icode = tyto.b64("Decode", match, 'I64.', '.I64') 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 = '
\n'%set_css + \
+                   '  '
+      
+      # closed marker
+      elif line.startswith(tyto.words_tags[12][1]):
+        html_bcode = '%s\n  \n'%html_bcode + \
+                     '
' + + # Block-code content per line + else: + html_bcode = '%s\n %s'%(html_bcode, line) + + article_bottom = article_bottom.replace(rep_bcode, html_bcode) + + + +