diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 0c84e67..babd408 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -86,6 +86,7 @@ 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 + wip_titles() # Quotes. Decode base64 Q64 and convert to HTML wip_quotes() @@ -454,24 +455,74 @@ def wip_bcodes(): # 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) + +#========================================# +# Convert titles to HTML # +# Check between titles to set div or not # +#----------------------------------------# +def wip_titles(): + global article_bottom + article_temp = article_bottom + article_tmp2 = '' # COnstruct article, without empty lines + + for line in article_bottom.rsplit('\n'): + if line.startswith('#'): + hx = line[1] + title_cont = line[2: len(line)].lstrip() + title_html = '%s'%(hx, hx, title_cont, hx) + article_temp = article_temp.replace(line, title_html) - - + + + # Remove useless empty lines from article + for line in article_temp.rsplit('\n'): + if line: + if article_tmp2: article_tmp2 = '%s\n%s'%(article_tmp2, line) + else: article_tmp2 = line + + article_temp = article_tmp2 + + # Add div after title if needed + for ln, line in enumerate(article_tmp2.rsplit('\n')): + if line.startswith(''%line + ) + + article_tmp2 = article_temp + # Add div after title if needed + indiv = False + for ln, line in enumerate(article_tmp2.rsplit('\n')): + if line.startswith('\n%s'%line + ) + indiv = False + + if indiv: + article_temp = '%s\n'%article_temp + + # Replace article with new contents + article_bottom = article_temp