wip: fix quotes. Added pre-tabs for html article
This commit is contained in:
parent
93b9fc7a2e
commit
6983ea89ed
|
@ -91,6 +91,7 @@ def wip_article(target):
|
||||||
wip_icodes() # inline_codes. Decode base64 icode and replace
|
wip_icodes() # inline_codes. Decode base64 icode and replace
|
||||||
wip_bcodes() # Block-codes. Decode B64 and convert to HTML
|
wip_bcodes() # Block-codes. Decode B64 and convert to HTML
|
||||||
wip_raws(target) # Read file and convert to HTML
|
wip_raws(target) # Read file and convert to HTML
|
||||||
|
wip_tabs() # make HTML tabulations
|
||||||
|
|
||||||
# Result (temp display)
|
# Result (temp display)
|
||||||
print(article_bottom)
|
print(article_bottom)
|
||||||
|
@ -311,6 +312,7 @@ def wip_quotes() :
|
||||||
# Read the quote. Get parameters
|
# Read the quote. Get parameters
|
||||||
author = date = lang = book = link = quote_html = ''
|
author = date = lang = book = link = quote_html = ''
|
||||||
cite = figc = ''
|
cite = figc = ''
|
||||||
|
tab_t = ''
|
||||||
tab_p = tab_c = 2 # Init 2 tabs after <blockquote>
|
tab_p = tab_c = 2 # Init 2 tabs after <blockquote>
|
||||||
auth_html = title_html = ''
|
auth_html = title_html = ''
|
||||||
|
|
||||||
|
@ -383,9 +385,13 @@ def wip_quotes() :
|
||||||
else:
|
else:
|
||||||
title_html = ' title="%s"'%author
|
title_html = ' title="%s"'%author
|
||||||
auth_html = '%s'%author
|
auth_html = '%s'%author
|
||||||
|
|
||||||
if link: figc= '<a class="figc" href="%s">%s</a>'%(
|
if link: figc= '<a class="figc" href="%s">%s</a>'%(
|
||||||
link, auth_html
|
link, auth_html
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
figc = '<span class="figc">%s</span>'%auth_html
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if book and date: title_html = ' title="%s (%s)"'%(
|
if book and date: title_html = ' title="%s (%s)"'%(
|
||||||
book, date
|
book, date
|
||||||
|
@ -395,8 +401,9 @@ def wip_quotes() :
|
||||||
|
|
||||||
time_html_o = time_html_c = ''
|
time_html_o = time_html_c = ''
|
||||||
if date:
|
if date:
|
||||||
time_html_o = '<time datetime="%s">\n'%date
|
if author: tab_t = ' '
|
||||||
time_html_c = '</time>\n'
|
time_html_o = '%s<time datetime="%s">\n'%(tab_t, date)
|
||||||
|
time_html_c = '%s</time>\n'%tab_t
|
||||||
|
|
||||||
# Create HTML Quote with datas
|
# Create HTML Quote with datas
|
||||||
if author:
|
if author:
|
||||||
|
@ -404,9 +411,9 @@ def wip_quotes() :
|
||||||
' <blockquote class="%s"%s%s%s>\n'%(
|
' <blockquote class="%s"%s%s%s>\n'%(
|
||||||
set_css, lang, cite, title_html
|
set_css, lang, cite, title_html
|
||||||
) + \
|
) + \
|
||||||
' ' + time_html_o + \
|
time_html_o + \
|
||||||
'%s\n'%quote_html + \
|
'%s\n'%quote_html + \
|
||||||
' ' + time_html_c + \
|
time_html_c + \
|
||||||
' </blockquote>\n' + \
|
' </blockquote>\n' + \
|
||||||
' <figcaption class="%s">\n'%set_css + \
|
' <figcaption class="%s">\n'%set_css + \
|
||||||
' %s\n'%figc + \
|
' %s\n'%figc + \
|
||||||
|
@ -521,15 +528,17 @@ def wip_titles():
|
||||||
article_tmp2 = article_temp
|
article_tmp2 = article_temp
|
||||||
indiv = False
|
indiv = False
|
||||||
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
for ln, line in enumerate(article_tmp2.rsplit('\n')):
|
||||||
|
try: article_tmp2.rsplit('\n')[ln + 1]
|
||||||
|
except: continue
|
||||||
|
|
||||||
if line.startswith('<h') and indiv:
|
if line.startswith('<h') and indiv:
|
||||||
article_temp = article_temp.replace(
|
article_temp = article_temp.replace(
|
||||||
line, '</div>\n%s'%line
|
line, '</div>\n%s'%line
|
||||||
)
|
)
|
||||||
indiv = False
|
indiv = False
|
||||||
|
|
||||||
if line.startswith('<h'):
|
#if line.startswith('<h'):
|
||||||
try: article_tmp2.rsplit('\n')[ln + 1]
|
|
||||||
except: continue
|
|
||||||
|
|
||||||
if article_tmp2.rsplit('\n')[ln + 1].startswith('<div'):
|
if article_tmp2.rsplit('\n')[ln + 1].startswith('<div'):
|
||||||
indiv = True
|
indiv = True
|
||||||
|
@ -542,9 +551,9 @@ def wip_titles():
|
||||||
article_bottom = article_temp
|
article_bottom = article_temp
|
||||||
|
|
||||||
|
|
||||||
#
|
#==============================================#
|
||||||
# Convert raw file to HTML with <pre> + <code>
|
# Convert raw file to HTML with <pre> + <code> #
|
||||||
#
|
#----------------------------------------------#
|
||||||
def wip_raws(target):
|
def wip_raws(target):
|
||||||
if uniq_raws == 0: return
|
if uniq_raws == 0: return
|
||||||
|
|
||||||
|
@ -568,3 +577,41 @@ def wip_raws(target):
|
||||||
article_bottom = article_bottom.replace(
|
article_bottom = article_bottom.replace(
|
||||||
eval(raw)[0], raw_html
|
eval(raw)[0], raw_html
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Make HTML tabulations
|
||||||
|
#
|
||||||
|
def wip_tabs():
|
||||||
|
global article_bottom
|
||||||
|
article_temp = ''
|
||||||
|
tab_start = 8 # From <article> tag
|
||||||
|
indiv = False
|
||||||
|
|
||||||
|
for line in article_bottom.rsplit('\n'):
|
||||||
|
# Titles
|
||||||
|
if line.startswith('<h'):
|
||||||
|
get_tab = line[2]
|
||||||
|
tab = int(tab_start) + 2 * int(get_tab)
|
||||||
|
if not article_temp: article_temp = '%s%s'%(tab * ' ', line)
|
||||||
|
else: article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# div
|
||||||
|
if line.startswith('<div'):
|
||||||
|
tab = int(tab) + 2
|
||||||
|
indiv = True
|
||||||
|
article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
|
||||||
|
tab = int(tab) + 2
|
||||||
|
continue
|
||||||
|
elif line.startswith('</div>'):
|
||||||
|
tab = int(tab) - 2
|
||||||
|
article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
|
||||||
|
indiv = False
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Other contents
|
||||||
|
else:
|
||||||
|
article_temp = '%s\n%s%s'%(article_temp, tab * ' ', line)
|
||||||
|
|
||||||
|
article_bottom = article_temp
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue