From 1ed0b860825fd7639546ee11c7c3fda655849b52 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Sat, 19 Nov 2022 16:56:08 +0100 Subject: [PATCH] wip: bcodes are converted with pre + span(s) --- src/var/lib/tyto/program/wip.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index d394f6b..cb485bc 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -129,8 +129,8 @@ def wip_begin_markers(wip_lines): ['^>>\s' , '' , True ], [r'^\($|\(\s' , '

' , True ], ['^\)$|^\)\s' , '

' , False], - ['^\[\[$|^\[\[\s' , '' , False] + ['^\[\[$|^\[\[\s' , '
'          , False]
                ]
 
   for line in wip_lines:
@@ -448,26 +448,34 @@ def convert_bcodes(article, fm, lm, css):
   article_temp = ''
   bCode        = False
   bCode_lines  = ''
+  bCode_ln     = 0
   
   for line in article:    
     if line.startswith(fm):
       bCode        = True
-      article_temp = '%s%s\n'%(article_temp, line)
+      article_temp = '%s\n%s'%(article_temp, line)
       continue
     
     if line.startswith(lm):
       bCode    = False
       
-      #print(bCode_lines)
+      print(bCode_lines)
       convert_to_b64(bCode_lines)
       bCode_lines  = ''
-      article_temp = '%s%s\n%s\n'%(
+      article_temp = '%s\n%s\n%s'%(
                       article_temp, b64_content, line
                       )
       continue
   
-    if bCode: bCode_lines  = '%s%s\n'%(bCode_lines, line)
-    else    : article_temp = '%s%s\n'%(article_temp, line)
+    if bCode:
+      bCode_ln += 1
+      line = '  %s%s'%(
+              bCode_ln, line
+              )
+      if bCode_lines: bCode_lines = '%s\n%s'%(bCode_lines, line)
+      else          : bCode_lines = line
+    else:
+      article_temp = '%s\n%s'%(article_temp, line)
 
 #====================================#
 # Protect bCodes contents to base64  #