Lots of changes. Need tests, but should work
This commit is contained in:
parent
43895adef7
commit
6671b03e95
|
@ -54,6 +54,7 @@ pass_db = \
|
||||||
'edit-wip',
|
'edit-wip',
|
||||||
'edit-www',
|
'edit-www',
|
||||||
'publish',
|
'publish',
|
||||||
|
'show',
|
||||||
'show-db',
|
'show-db',
|
||||||
'show-wip',
|
'show-wip',
|
||||||
'show-www',
|
'show-www',
|
||||||
|
|
|
@ -35,7 +35,7 @@ def manage_check(target):
|
||||||
# target needed
|
# target needed
|
||||||
if not target: logs.out("5", '', True)
|
if not target: logs.out("5", '', True)
|
||||||
|
|
||||||
global date_wip, hash_wip, date_www, hash_www
|
global date_wip, hash_wip, date_www, hash_www, post_bottom
|
||||||
date_wip = hash_wip = date_www = hash_www = ''
|
date_wip = hash_wip = date_www = hash_www = ''
|
||||||
|
|
||||||
# Article has DB
|
# Article has DB
|
||||||
|
@ -100,26 +100,28 @@ def manage_check(target):
|
||||||
file_to_string(db.uri_file)
|
file_to_string(db.uri_file)
|
||||||
|
|
||||||
# Specific to inline-code: check markers on same line
|
# Specific to inline-code: check markers on same line
|
||||||
check_icodes(article.rsplit('\n'))
|
if_icodes_bcodes_quotes(post_bottom)
|
||||||
|
|
||||||
# Protect inline-codes
|
|
||||||
tyto.protect_icodes(post_bottom, article_bottom)
|
|
||||||
post_bottom = tyto.protect_article.rsplit('\n')
|
|
||||||
article_bottom = tyto.protect_article
|
|
||||||
|
|
||||||
# Protect block-codes and quotes
|
# Protect block-codes and quotes
|
||||||
tyto.protect_bcodes_quotes('check', post_bottom, article_bottom)
|
if bcode or quote:
|
||||||
post_bottom = tyto.protect_article.rsplit('\n')
|
tyto.protect_bcodes_quotes('check', post_bottom)
|
||||||
article_bottom = tyto.protect_article
|
post_bottom = tyto.protect_article
|
||||||
|
|
||||||
|
# Protect inline-codes
|
||||||
|
if icode:
|
||||||
|
tyto.protect_icodes(post_bottom)
|
||||||
|
post_bottom = tyto.protect_article
|
||||||
|
|
||||||
|
|
||||||
# Count words in article. Quotes, block-codes, icode = 1 per each
|
# Count words in article. Quotes, block-codes, icode = 1 per each
|
||||||
post_words = len(article_bottom.strip().split(" "))
|
post_words = len(post_bottom.strip().split(" "))
|
||||||
|
|
||||||
# Check for valid contents
|
# Check for valid contents
|
||||||
check_content(post_bottom)
|
check_content(post_bottom)
|
||||||
post_bottom = article_bottom.rsplit('\n')
|
post_bottom = post_bottom.rsplit('\n')
|
||||||
|
|
||||||
check_headers(post_header)
|
#post_header = post_header.rsplit('\n')
|
||||||
|
check_headers(post_header.rsplit('\n'))
|
||||||
|
|
||||||
# Exit if unused needed tags
|
# Exit if unused needed tags
|
||||||
if post_err:
|
if post_err:
|
||||||
|
@ -131,62 +133,81 @@ def manage_check(target):
|
||||||
create_database()
|
create_database()
|
||||||
|
|
||||||
|
|
||||||
#=====================#
|
|
||||||
# Find in post_bottom #
|
|
||||||
#---------------------#
|
|
||||||
def isin(term, post_bottom):
|
|
||||||
for x in post_bottom:
|
|
||||||
if re.search(r'%s'%term, x):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
#=================================#
|
#=================================#
|
||||||
# Create string article from file #
|
# Create string article from file #
|
||||||
# Check if separator or exit #
|
# Check if separator or exit #
|
||||||
#---------------------------------#
|
#---------------------------------#
|
||||||
def file_to_string(post_file):
|
def file_to_string(post_file):
|
||||||
global article
|
global article
|
||||||
global article_header, article_bottom
|
|
||||||
global post_header, post_bottom
|
global post_header, post_bottom
|
||||||
|
|
||||||
|
post_header = post_bottom = ''
|
||||||
|
sep = False
|
||||||
article = open(post_file, 'r').read()
|
article = open(post_file, 'r').read()
|
||||||
|
|
||||||
|
for line in article.rsplit('\n'):
|
||||||
|
if line.startswith('-----'):
|
||||||
|
sep = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if sep:
|
||||||
|
if not post_bottom: post_bottom = line
|
||||||
|
else: post_bottom = '%s\n%s'%(post_bottom, line)
|
||||||
|
else:
|
||||||
|
if not post_header: post_header = line
|
||||||
|
else: post_header = '%s\n%s'%(post_header, line)
|
||||||
|
|
||||||
# Check if separator or exit
|
# Check if separator or exit
|
||||||
if not '-----' in article: logs.out("6", '-----', True)
|
if not sep:
|
||||||
|
logs.out("6", '-----', True)
|
||||||
# Set from separator, NOT splitted by new line
|
|
||||||
article_header = article.rsplit('-----')[0]
|
|
||||||
article_bottom = article.rsplit('-----')[1]
|
|
||||||
|
|
||||||
# Set from separator, splitted by new line
|
|
||||||
post_header = article.rsplit('-----')[0].rsplit('\n')
|
|
||||||
post_bottom = article.rsplit('-----')[1].rsplit('\n')
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================#
|
#=============================================#
|
||||||
|
# Check if bcodes and quotes #
|
||||||
# Check inline code, for markers on same line #
|
# Check inline code, for markers on same line #
|
||||||
|
# Stats for titles, quotes, bcodes, uniq_ancs #
|
||||||
#---------------------------------------------#
|
#---------------------------------------------#
|
||||||
def check_icodes(article):
|
def if_icodes_bcodes_quotes(post_bottom):
|
||||||
quote = bcode = False
|
global icode, quote, bcode
|
||||||
|
global nbr_titles, nbr_quotes, nbr_bcodes, nbr_ancs
|
||||||
|
icode = quote = in_quote = bcode = in_bcode = False
|
||||||
|
nbr_titles = nbr_quotes = nbr_bcodes = nbr_ancs = 0
|
||||||
|
|
||||||
for ln, line in enumerate(article, 1):
|
for ln, line in enumerate(post_bottom.rsplit('\n'), 1):
|
||||||
icode_m1 = icode_m2 = 0
|
# Pass Comments, count titles
|
||||||
|
# Count titles
|
||||||
# Pass Comments
|
if not line:
|
||||||
if line.startswith('#'): continue
|
continue
|
||||||
|
elif line.startswith(tyto.titles_tags):
|
||||||
|
nbr_titles += 1
|
||||||
|
continue
|
||||||
|
elif line.startswith('#'):
|
||||||
|
continue
|
||||||
|
|
||||||
# Pass quotes
|
# Pass quotes
|
||||||
if line.startswith(tyto.words_tags[11][0]): quote = True
|
elif line.startswith(tyto.words_tags[11][0]) and not in_bcode:
|
||||||
if line.startswith(tyto.words_tags[11][1]): quote = False
|
quote = in_quote = True
|
||||||
|
nbr_quotes += 1
|
||||||
|
continue
|
||||||
|
elif line.startswith(tyto.words_tags[11][1]):
|
||||||
|
in_quote = False
|
||||||
|
continue
|
||||||
|
|
||||||
# Pass bcode
|
# Pass bcode
|
||||||
if line.startswith(tyto.words_tags[12][0]): bcode = True
|
elif line.startswith(tyto.words_tags[12][0]) and not in_quote:
|
||||||
if line.startswith(tyto.words_tags[12][1]): bcode = False
|
bcode = in_bcode = True
|
||||||
|
nbr_bcodes += 1
|
||||||
|
continue
|
||||||
|
elif line.startswith(tyto.words_tags[12][1]):
|
||||||
|
in_bcode = False
|
||||||
|
continue
|
||||||
|
|
||||||
if bcode or quote: continue
|
if in_bcode or in_quote:
|
||||||
|
continue
|
||||||
if tyto.words_tags[9][0] or tyto.words_tags[9][1] in line:
|
elif line.startswith(tyto.single_tags[1][0]):
|
||||||
|
nbr_ancs += 1
|
||||||
|
elif tyto.words_tags[9][0] or tyto.words_tags[9][1] in line:
|
||||||
|
icode_m1 = icode_m2 = 0
|
||||||
icode_m1 = line.count(tyto.words_tags[9][0])
|
icode_m1 = line.count(tyto.words_tags[9][0])
|
||||||
icode_m2 = line.count(tyto.words_tags[9][1])
|
icode_m2 = line.count(tyto.words_tags[9][1])
|
||||||
if icode_m1 != icode_m2:
|
if icode_m1 != icode_m2:
|
||||||
|
@ -194,6 +215,8 @@ def check_icodes(article):
|
||||||
tyto.words_tags[9][0], tyto.words_tags[9][1]
|
tyto.words_tags[9][0], tyto.words_tags[9][1]
|
||||||
), True
|
), True
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
icode = True
|
||||||
|
|
||||||
|
|
||||||
#==================================#
|
#==================================#
|
||||||
|
@ -226,7 +249,6 @@ def check_headers(post_header):
|
||||||
# Read articles lines, till separator #
|
# Read articles lines, till separator #
|
||||||
#-------------------------------------#
|
#-------------------------------------#
|
||||||
for ln, line in enumerate(post_header, 1):
|
for ln, line in enumerate(post_header, 1):
|
||||||
|
|
||||||
# Set each needed tag #
|
# Set each needed tag #
|
||||||
# Only the first one is set #
|
# Only the first one is set #
|
||||||
#---------------------------#
|
#---------------------------#
|
||||||
|
@ -283,7 +305,7 @@ def check_headers(post_header):
|
||||||
# Check if set needed tags
|
# Check if set needed tags
|
||||||
for tag in need_headers:
|
for tag in need_headers:
|
||||||
if not need_headers[tag]:
|
if not need_headers[tag]:
|
||||||
logs_out("6", tag, False)
|
logs.out("6", tag, False)
|
||||||
post_err = True
|
post_err = True
|
||||||
|
|
||||||
|
|
||||||
|
@ -573,7 +595,6 @@ def check_file_uri(filetype, filename, ln):
|
||||||
#---------------------------#
|
#---------------------------#
|
||||||
def check_content(post_bottom):
|
def check_content(post_bottom):
|
||||||
global post_err
|
global post_err
|
||||||
global article_bottom
|
|
||||||
|
|
||||||
# Check tags for words (strongs, italics...)
|
# Check tags for words (strongs, italics...)
|
||||||
# Set stats for each one
|
# Set stats for each one
|
||||||
|
@ -582,13 +603,13 @@ def check_content(post_bottom):
|
||||||
c_opened = c_closed = 0
|
c_opened = c_closed = 0
|
||||||
|
|
||||||
if tag[5] == 'w':
|
if tag[5] == 'w':
|
||||||
c_opened = article_bottom.count(tag[0])
|
c_opened = post_bottom.count(tag[0])
|
||||||
c_closed = article_bottom.count(tag[1])
|
c_closed = post_bottom.count(tag[1])
|
||||||
# Useless tag now, replace
|
# Useless tag now, replace
|
||||||
article_bottom = article_bottom.replace(tag[0], '')
|
post_bottom = post_bottom.replace(tag[0], '')
|
||||||
article_bottom = article_bottom.replace(tag[1], '')
|
post_bottom = post_bottom.replace(tag[1], '')
|
||||||
elif tag[5] == 't':
|
elif tag[5] == 't':
|
||||||
for line in post_bottom:
|
for line in post_bottom.rsplit('\n'):
|
||||||
if line.startswith(tag[0]): c_opened += 1
|
if line.startswith(tag[0]): c_opened += 1
|
||||||
if line.startswith(tag[1]): c_closed += 1
|
if line.startswith(tag[1]): c_closed += 1
|
||||||
|
|
||||||
|
@ -603,11 +624,8 @@ def check_content(post_bottom):
|
||||||
# Check if anchor has target
|
# Check if anchor has target
|
||||||
# Count anchors target
|
# Count anchors target
|
||||||
#---------------------------
|
#---------------------------
|
||||||
global stat_ancs
|
for line in post_bottom.rsplit('\n'):
|
||||||
stat_ancs = 0
|
# Anchor link
|
||||||
|
|
||||||
for line in post_bottom:
|
|
||||||
if line.startswith(tyto.single_tags[1][0]): stat_ancs += 1
|
|
||||||
if tyto.words_tags[0][0] and tyto.words_tags[0][1] in line:
|
if tyto.words_tags[0][0] and tyto.words_tags[0][1] in line:
|
||||||
anchors = re.findall(r">_(.*?)_<", line)
|
anchors = re.findall(r">_(.*?)_<", line)
|
||||||
for anchor in anchors:
|
for anchor in anchors:
|
||||||
|
@ -617,6 +635,16 @@ def check_content(post_bottom):
|
||||||
logs.out("6", 'anchor, %s'%tag, False)
|
logs.out("6", 'anchor, %s'%tag, False)
|
||||||
post_err = True
|
post_err = True
|
||||||
|
|
||||||
|
# Anchor source "->"
|
||||||
|
elif line.startswith(tyto.single_tags[1][0]):
|
||||||
|
set_css = tyto.get_css(line)
|
||||||
|
is_uniq_anchor = "%s %s"%(tyto.single_tags[1][0], set_css)
|
||||||
|
c_uniq_anchor = post_bottom.count(is_uniq_anchor)
|
||||||
|
if c_uniq_anchor > 1:
|
||||||
|
logs.out("15", '%s "%s"'%(c_uniq_anchor, is_uniq_anchor), False)
|
||||||
|
post_err = True
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
# Lists: check if contents are valid
|
# Lists: check if contents are valid
|
||||||
#-----------------------------------
|
#-----------------------------------
|
||||||
|
@ -663,8 +691,8 @@ def check_content(post_bottom):
|
||||||
# Template Tags (warning for not paired symbols)
|
# Template Tags (warning for not paired symbols)
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
for tag in tyto.tpl_tags:
|
for tag in tyto.tpl_tags:
|
||||||
tpl1 = article_bottom.count(tag[0])
|
tpl1 = post_bottom.count(tag[0])
|
||||||
tpl2 = article_bottom.count(tag[1])
|
tpl2 = post_bottom.count(tag[1])
|
||||||
|
|
||||||
if tpl1 != tpl2:
|
if tpl1 != tpl2:
|
||||||
logs.out("22", '"%s", "%s"'%(tag[0], tag[1]), False)
|
logs.out("22", '"%s", "%s"'%(tag[0], tag[1]), False)
|
||||||
|
@ -735,7 +763,7 @@ def create_database():
|
||||||
)
|
)
|
||||||
|
|
||||||
db_stats = '\n# Statistics from optional tags\n' + \
|
db_stats = '\n# Statistics from optional tags\n' + \
|
||||||
'uniq_anchors = %d\n'%stat_ancs + \
|
'uniq_anchors = %d\n'%nbr_ancs + \
|
||||||
'uniq_abbrs = %d\n'%stat_abbrs + \
|
'uniq_abbrs = %d\n'%stat_abbrs + \
|
||||||
'uniq_links = %d\n'%stat_links + \
|
'uniq_links = %d\n'%stat_links + \
|
||||||
'uniq_images = %d\n'%stat_images + \
|
'uniq_images = %d\n'%stat_images + \
|
||||||
|
@ -744,7 +772,7 @@ def create_database():
|
||||||
'\n# Statistics from post content\n' + \
|
'\n# Statistics from post content\n' + \
|
||||||
'stat_tags = %d\n'%post_tags + \
|
'stat_tags = %d\n'%post_tags + \
|
||||||
'stat_words = %d\n'%post_words + \
|
'stat_words = %d\n'%post_words + \
|
||||||
'stat_titles = %d\n'%tyto.nbr_titles + \
|
'stat_titles = %d\n'%nbr_titles + \
|
||||||
'stat_paragraphs = %d\n'%post_paragraphs + \
|
'stat_paragraphs = %d\n'%post_paragraphs + \
|
||||||
'stat_anchors = %d\n'%post_anchors + \
|
'stat_anchors = %d\n'%post_anchors + \
|
||||||
'stat_strongs = %d\n'%post_strongs + \
|
'stat_strongs = %d\n'%post_strongs + \
|
||||||
|
@ -756,10 +784,23 @@ def create_database():
|
||||||
'stat_cites = %d\n'%post_cites + \
|
'stat_cites = %d\n'%post_cites + \
|
||||||
'stat_customs = %d\n'%post_customs + \
|
'stat_customs = %d\n'%post_customs + \
|
||||||
'stat_icodes = %d\n'%tyto.nbr_icodes + \
|
'stat_icodes = %d\n'%tyto.nbr_icodes + \
|
||||||
'stat_bcodes = %d\n'%tyto.nbr_bcodes + \
|
'stat_bcodes = %d\n'%nbr_bcodes + \
|
||||||
'stat_quotes = %d\n'%tyto.nbr_quotes + \
|
'stat_quotes = %d\n'%nbr_quotes + \
|
||||||
'stat_lists = %d\n'%post_lists
|
'stat_lists = %d\n'%post_lists
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
database = '%s\n%s'%(database, db_stats)
|
database = '%s\n%s'%(database, db_stats)
|
||||||
tyto.set_file(db.post_db, 'new', database)
|
tyto.set_file(db.post_db, 'new', database)
|
||||||
logs.out("21", '', True)
|
logs.out("21", '', True)
|
||||||
|
|
||||||
|
|
||||||
|
#=====================#
|
||||||
|
# Find in post_bottom #
|
||||||
|
#---------------------#
|
||||||
|
def isin(term, post_bottom):
|
||||||
|
for x in post_bottom:
|
||||||
|
if re.search(r'%s'%term, x):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
|
@ -44,6 +44,7 @@ def out(nbr, value, out):
|
||||||
'12' : ':< %sUnused "%s"%s in article\'s header'%(CR, value, CS),
|
'12' : ':< %sUnused "%s"%s in article\'s header'%(CR, value, CS),
|
||||||
'13' : ':< %sNo file or directory%s here (deleted ?)'%(CR, CS),
|
'13' : ':< %sNo file or directory%s here (deleted ?)'%(CR, CS),
|
||||||
'14' : ':< %sMismatch%s program start'%(CR, CS),
|
'14' : ':< %sMismatch%s program start'%(CR, CS),
|
||||||
|
'15' : ':< Anchor %snot uniq%s: %s'%(CR, CS, value),
|
||||||
'19' : ':D Article %swip%s on: %s'%(CG, CS, value),
|
'19' : ':D Article %swip%s on: %s'%(CG, CS, value),
|
||||||
'20' : ':D Article %scheck%s on: %s'%(CG, CS, value),
|
'20' : ':D Article %scheck%s on: %s'%(CG, CS, value),
|
||||||
'21' : ':D Article %sValid%s. Ready to wip'%(CG, CS),
|
'21' : ':D Article %sValid%s. Ready to wip'%(CG, CS),
|
||||||
|
|
|
@ -244,24 +244,117 @@ def get_css(line):
|
||||||
return set_css
|
return set_css
|
||||||
|
|
||||||
|
|
||||||
|
#=============================================#
|
||||||
|
# First check process to protect contents #
|
||||||
|
# Protect block-Codes, quotes #
|
||||||
|
# Also remove empty/commented lines #
|
||||||
|
# Used in check and wip #
|
||||||
|
# check: create string without quotes, bcodes #
|
||||||
|
# wip: remplace quotes, bcode with base64 #
|
||||||
|
#---------------------------------------------#
|
||||||
|
def protect_bcodes_quotes(process, post_bottom):
|
||||||
|
global protect_article
|
||||||
|
global nbr_titles, nbr_bcodes, nbr_quotes # Stats for DB
|
||||||
|
|
||||||
|
in_bcode = in_quote = False
|
||||||
|
protect_article = ''
|
||||||
|
bcode = quote = '' # Only for wip process
|
||||||
|
|
||||||
|
for line in post_bottom.rsplit('\n'):
|
||||||
|
start_bcode = close_bcode = False
|
||||||
|
start_quote = close_quote = False
|
||||||
|
|
||||||
|
# Settings and counters
|
||||||
|
#----------------------
|
||||||
|
# Bcode (at close, replace with base64)
|
||||||
|
if not in_quote:
|
||||||
|
if line.startswith(words_tags[12][0]): # Open
|
||||||
|
start_bcode = True
|
||||||
|
in_bcode = True
|
||||||
|
elif line.startswith(words_tags[12][1]): # Close
|
||||||
|
close_bcode = True
|
||||||
|
in_bcode = False
|
||||||
|
if process == "wip":
|
||||||
|
bcode = '%s\n%s'%(bcode, line)
|
||||||
|
b64_bcode = b64('Encode', bcode, 'B64.', '.B64')
|
||||||
|
line = b64_bcode
|
||||||
|
|
||||||
|
# Quote (at close, replace with base64)
|
||||||
|
if not in_bcode:
|
||||||
|
if line.startswith(words_tags[11][0]): # Open
|
||||||
|
start_quote = True
|
||||||
|
in_quote = True
|
||||||
|
elif line.startswith(words_tags[11][1]): # Close
|
||||||
|
close_quote = True
|
||||||
|
in_quote = False
|
||||||
|
if process == "wip":
|
||||||
|
quote = '%s\n%s'%(quote, line)
|
||||||
|
b64_quote = b64('Encode', quote, 'Q64.', '.Q64')
|
||||||
|
line = b64_quote
|
||||||
|
|
||||||
|
if not in_quote and not in_bcode:
|
||||||
|
if not line: continue
|
||||||
|
if line.startswith('#') and not line.startswith(titles_tags):
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
# Counters and keep tags for check process
|
||||||
|
#-----------------------------------------
|
||||||
|
if process == "check":
|
||||||
|
if in_bcode and not start_bcode \
|
||||||
|
or in_quote and not start_quote :
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
# Set new article content for wip process
|
||||||
|
#----------------------------------------
|
||||||
|
elif process == "wip":
|
||||||
|
# bcode convertion to base64
|
||||||
|
if in_bcode:
|
||||||
|
# Convert lines to b64
|
||||||
|
if not bcode: bcode = line
|
||||||
|
else: bcode = '%s\n%s'%(bcode, line)
|
||||||
|
line = ''
|
||||||
|
elif in_quote:
|
||||||
|
# Convert lines to b64
|
||||||
|
if not quote: quote = line
|
||||||
|
else: quote = '%s\n%s'%(quote, line)
|
||||||
|
line = ''
|
||||||
|
|
||||||
|
|
||||||
|
# Set new content
|
||||||
|
#----------------
|
||||||
|
# check: remove quote/bcode, keep tags
|
||||||
|
# wip: replace close tag with quote/bcode (keep in open tag)
|
||||||
|
if not line: continue
|
||||||
|
if not protect_article: protect_article = line
|
||||||
|
else: protect_article = '%s\n%s'%(protect_article, line)
|
||||||
|
|
||||||
|
|
||||||
|
# Clean in wip process for new quote/bcode
|
||||||
|
if process == "wip":
|
||||||
|
if close_bcode: bcode = b64_bcode = ''
|
||||||
|
if close_quote: quote = b64_quote = ''
|
||||||
|
|
||||||
|
|
||||||
#=======================#
|
#=======================#
|
||||||
# Protec iCodes #
|
# Protec iCodes #
|
||||||
# Used in check and wip #
|
# Used in check and wip #
|
||||||
#-----------------------~
|
#-----------------------~
|
||||||
def protect_icodes(post_bottom, article_bottom):
|
def protect_icodes(post_bottom):
|
||||||
global protect_article
|
global protect_article
|
||||||
global nbr_icodes
|
global nbr_icodes
|
||||||
|
|
||||||
nbr_icodes = 0 # Stats here for DB as content will change
|
nbr_icodes = 0 # Stats here for DB as content will change
|
||||||
protect_article = article_bottom
|
protect_article = post_bottom
|
||||||
incode = False
|
in_icode = False
|
||||||
src_code = rep_code = ''
|
src_code = rep_code = ''
|
||||||
|
|
||||||
# Get only lines that contains code
|
# Get only lines that contains code
|
||||||
for ln, line in enumerate(post_bottom):
|
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||||
if words_tags[9][0] and words_tags[9][1] in line:
|
if not words_tags[9][0] in line: continue
|
||||||
|
|
||||||
# Iterate in line
|
# Iterate (c)haracter in line
|
||||||
for i, c in enumerate(line):
|
for i, c in enumerate(line):
|
||||||
c_b = c_bb = c_a = ""
|
c_b = c_bb = c_a = ""
|
||||||
if c == '_':
|
if c == '_':
|
||||||
|
@ -271,112 +364,31 @@ def protect_icodes(post_bottom, article_bottom):
|
||||||
|
|
||||||
# incode if
|
# incode if
|
||||||
if c_b == '{' and not c_bb == '\\':
|
if c_b == '{' and not c_bb == '\\':
|
||||||
incode = True
|
in_icode = True
|
||||||
nbr_icodes += 1
|
nbr_icodes += 1
|
||||||
code = words_tags[9][2]
|
code = words_tags[9][2]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# No more in code if
|
# No more in code if
|
||||||
if c_a == '}' and not c_b == '\\':
|
if c_a == '}' and not c_b == '\\':
|
||||||
incode = False
|
in_icode = False
|
||||||
code = '%s%s%s'%(code, src_code, words_tags[9][3])
|
code = '%s%s%s'%(code, src_code, words_tags[9][3])
|
||||||
b64_code = b64('Encode', code, 'I64.', '.I64')
|
b64_code = b64('Encode', code, 'I64.', '.I64')
|
||||||
rep_code = "%s%s%s"%(
|
rep_code = "%s%s%s"%(
|
||||||
words_tags[9][0], rep_code, words_tags[9][1]
|
words_tags[9][0], rep_code, words_tags[9][1]
|
||||||
)
|
)
|
||||||
temp_post = protect_article.replace(rep_code, b64_code)
|
protect_article = protect_article.replace(rep_code, b64_code)
|
||||||
protect_article = temp_post
|
|
||||||
|
|
||||||
src_code = rep_code = b64_code = ''
|
src_code = rep_code = b64_code = ''
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Construct original replacement code and source code
|
# Construct original replacement code and source code
|
||||||
if incode:
|
if in_icode:
|
||||||
rep_code = '%s%s'%(rep_code, c)
|
rep_code = '%s%s'%(rep_code, c)
|
||||||
if c == '\\': continue
|
if c == '\\': continue
|
||||||
src_code = '%s%s'%(src_code, c)
|
src_code = '%s%s'%(src_code, c)
|
||||||
|
|
||||||
|
|
||||||
#=============================================#
|
|
||||||
# Protect block-Codes, quotes #
|
|
||||||
# Also remove commented lines #
|
|
||||||
# Used in check and wip #
|
|
||||||
# check: create string without quotes, bcode #
|
|
||||||
# wip: remplace quotes, bcode with base64 #
|
|
||||||
#---------------------------------------------#
|
|
||||||
def protect_bcodes_quotes(process, post_bottom, article_bottom):
|
|
||||||
global protect_article
|
|
||||||
global nbr_titles, nbr_bcodes, nbr_quotes # Stats for DB
|
|
||||||
|
|
||||||
in_bcode = in_quote = False
|
|
||||||
end_bcode = end_quote = False
|
|
||||||
protect_article = ''
|
|
||||||
temp_article = article_bottom
|
|
||||||
nbr_titles = nbr_bcodes = nbr_quotes = 0
|
|
||||||
bcode = quote = ''
|
|
||||||
|
|
||||||
|
|
||||||
for line in post_bottom:
|
|
||||||
# Bcode
|
|
||||||
if not in_quote:
|
|
||||||
if line.startswith(words_tags[12][0]):
|
|
||||||
in_bcode = True
|
|
||||||
if process == 'check':
|
|
||||||
if not protect_article: protect_article = line
|
|
||||||
else: protect_article = '%s\n%s'%(protect_article, line)
|
|
||||||
nbr_bcodes += 1
|
|
||||||
elif line.startswith(words_tags[12][1]):
|
|
||||||
if process == "wip":
|
|
||||||
bcode = '%s\n%s'%(bcode, line)
|
|
||||||
b64_bcode = b64('Encode', bcode, 'B64.', '.B64')
|
|
||||||
line = b64_bcode
|
|
||||||
end_bcode = True
|
|
||||||
in_bcode = False
|
|
||||||
|
|
||||||
# Quote
|
|
||||||
if not in_bcode:
|
|
||||||
if line.startswith(words_tags[11][0]):
|
|
||||||
in_quote = True
|
|
||||||
if process == 'check':
|
|
||||||
if not protect_article: protect_article = line
|
|
||||||
else: protect_article = '%s\n%s'%(protect_article, line)
|
|
||||||
nbr_quotes += 1
|
|
||||||
elif line.startswith(words_tags[11][1]):
|
|
||||||
if process == "wip":
|
|
||||||
quote = '%s\n%s'%(quote, line)
|
|
||||||
b64_quote = b64('Encode', quote, 'Q64.', '.Q64')
|
|
||||||
line = b64_quote
|
|
||||||
end_quote = True
|
|
||||||
in_quote = False
|
|
||||||
|
|
||||||
# Count titles for check
|
|
||||||
# Pass if line is a comment
|
|
||||||
if not in_bcode and not in_quote:
|
|
||||||
if line.startswith(titles_tags):
|
|
||||||
if process == 'check':
|
|
||||||
nbr_titles += 1
|
|
||||||
elif line.startswith('#'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if in_bcode:
|
|
||||||
if not bcode: bcode = line
|
|
||||||
else: bcode = '%s\n%s'%(bcode, line)
|
|
||||||
|
|
||||||
elif in_quote:
|
|
||||||
if line.startswith('#'): continue
|
|
||||||
if not quote: quote = line
|
|
||||||
else: quote = '%s\n%s'%(quote, line)
|
|
||||||
|
|
||||||
if end_bcode: bcode = ''; end_bcode = False ; in_bcode = False
|
|
||||||
elif end_quote: quote = ''; end_quote = False ; in_quote = False
|
|
||||||
|
|
||||||
if in_quote or in_bcode:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if not protect_article: protect_article = line
|
|
||||||
else: protect_article = '%s\n%s'%(protect_article, line)
|
|
||||||
|
|
||||||
|
|
||||||
#=====================================#
|
#=====================================#
|
||||||
# Encode/Decode string to/from base64 #
|
# Encode/Decode string to/from base64 #
|
||||||
# Data protection in UTF8 #
|
# Data protection in UTF8 #
|
||||||
|
|
|
@ -30,6 +30,8 @@ def manage_wip(target):
|
||||||
# Check if can process
|
# Check if can process
|
||||||
domain.domain_needed()
|
domain.domain_needed()
|
||||||
|
|
||||||
|
wip_article(db.post_src)
|
||||||
|
return
|
||||||
|
|
||||||
# Option 'all' to wip again, based on DB
|
# Option 'all' to wip again, based on DB
|
||||||
#---------------------------------------
|
#---------------------------------------
|
||||||
|
@ -106,18 +108,19 @@ def wip_article(target):
|
||||||
# Convert file to strings
|
# Convert file to strings
|
||||||
file_to_string(target)
|
file_to_string(target)
|
||||||
|
|
||||||
global post_header, article_header
|
global post_header
|
||||||
global post_bottom, article_bottom
|
global post_bottom
|
||||||
|
|
||||||
# Protect block-codes and quotes
|
# Protect block-codes and quotes
|
||||||
tyto.protect_bcodes_quotes('wip', post_bottom, article_bottom)
|
if db.stat_bcodes or db.stat_quotes > 0:
|
||||||
post_bottom = tyto.protect_article.rsplit('\n')
|
tyto.protect_bcodes_quotes('wip', post_bottom)
|
||||||
article_bottom = tyto.protect_article
|
post_bottom = tyto.protect_article
|
||||||
|
|
||||||
# Protect inline-codes
|
# Protect inline-codes
|
||||||
tyto.protect_icodes(post_bottom, article_bottom)
|
if db.stat_icodes > 0:
|
||||||
post_bottom = tyto.protect_article.rsplit('\n')
|
tyto.protect_icodes(post_bottom)
|
||||||
article_bottom = tyto.protect_article
|
post_bottom = tyto.protect_article
|
||||||
|
|
||||||
|
|
||||||
# Convert contents from modules
|
# Convert contents from modules
|
||||||
wip_single_tags() # br /, anchors
|
wip_single_tags() # br /, anchors
|
||||||
|
@ -139,7 +142,7 @@ def wip_article(target):
|
||||||
tyto.replace_in_db(db.post_db, 'wip', db.hash_post)
|
tyto.replace_in_db(db.post_db, 'wip', db.hash_post)
|
||||||
|
|
||||||
# Get article DB in html.py
|
# Get article DB in html.py
|
||||||
html.set_page(db.uri_file, article_bottom)
|
html.set_page(db.uri_file, post_bottom)
|
||||||
#print(html.main_page)
|
#print(html.main_page)
|
||||||
|
|
||||||
# Create wip file
|
# Create wip file
|
||||||
|
@ -156,38 +159,42 @@ def wip_article(target):
|
||||||
# post is string splitted '\n' #
|
# post is string splitted '\n' #
|
||||||
# article is string not splitted #
|
# article is string not splitted #
|
||||||
#---------------------------------#
|
#---------------------------------#
|
||||||
def file_to_string(target):
|
def file_to_string(post_file):
|
||||||
global article
|
global article
|
||||||
global article_header, article_bottom
|
|
||||||
global post_header, post_bottom
|
global post_header, post_bottom
|
||||||
|
|
||||||
article = open(target, 'r').read()
|
post_header = post_bottom = ''
|
||||||
|
sep = False
|
||||||
|
article = open(post_file, 'r').read()
|
||||||
|
|
||||||
# Set from separator, NOT splitted by new line
|
for line in article.rsplit('\n'):
|
||||||
article_header = article.rsplit('-----')[0]
|
if line.startswith('-----'):
|
||||||
article_bottom = article.rsplit('-----')[1]
|
sep = True
|
||||||
|
continue
|
||||||
|
|
||||||
# Set from separator, splitted by new line
|
if sep:
|
||||||
post_header = article.rsplit('-----')[0].rsplit('\n')
|
if not post_bottom: post_bottom = line
|
||||||
post_bottom = article.rsplit('-----')[1].rsplit('\n')
|
else: post_bottom = '%s\n%s'%(post_bottom, line)
|
||||||
|
else:
|
||||||
|
if not post_header: post_header = line
|
||||||
|
else: post_header = '%s\n%s'%(post_header, line)
|
||||||
|
|
||||||
|
|
||||||
#=============================#
|
#=============================#
|
||||||
# Convert tags (br /, anchor) #
|
# Convert tags (br /, anchor) #
|
||||||
#-----------------------------#
|
#-----------------------------#
|
||||||
def wip_single_tags():
|
def wip_single_tags():
|
||||||
global article_bottom
|
global post_bottom
|
||||||
|
|
||||||
# <br /> from "|"
|
# <br /> from "|"
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(tyto.single_tags[0][0],
|
||||||
tyto.single_tags[0][0], tyto.single_tags[0][1]
|
tyto.single_tags[0][1]
|
||||||
)
|
)
|
||||||
|
|
||||||
for line in article_bottom.rsplit('\n'):
|
for line in post_bottom.rsplit('\n'):
|
||||||
if line.startswith(tyto.single_tags[1][0]):
|
if line.startswith(tyto.single_tags[1][0]):
|
||||||
set_css = tyto.get_css(line)
|
set_css = tyto.get_css(line)
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(line,
|
||||||
line,
|
|
||||||
tyto.single_tags[1][1]%set_css
|
tyto.single_tags[1][1]%set_css
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -197,7 +204,7 @@ def wip_single_tags():
|
||||||
# Convert Paragraphs #
|
# Convert Paragraphs #
|
||||||
#----------------------------------#
|
#----------------------------------#
|
||||||
def wip_words_tags():
|
def wip_words_tags():
|
||||||
global article_bottom
|
global post_bottom
|
||||||
|
|
||||||
# Strongs, italics...
|
# Strongs, italics...
|
||||||
# (Stop after 8 tags)
|
# (Stop after 8 tags)
|
||||||
|
@ -207,38 +214,38 @@ def wip_words_tags():
|
||||||
if m == 0:
|
if m == 0:
|
||||||
m += 1
|
m += 1
|
||||||
# Close anchor (generic)
|
# Close anchor (generic)
|
||||||
article_bottom = article_bottom.replace(tag[1], tag[3])
|
post_bottom = post_bottom.replace(tag[1], tag[3])
|
||||||
continue
|
continue
|
||||||
elif m > 8: break
|
elif m > 8: break
|
||||||
|
|
||||||
# Open tag
|
# Open tag
|
||||||
article_bottom = article_bottom.replace(tag[0], tag[2])
|
post_bottom = post_bottom.replace(tag[0], tag[2])
|
||||||
# Close tag
|
# Close tag
|
||||||
article_bottom = article_bottom.replace(tag[1], tag[3])
|
post_bottom = post_bottom.replace(tag[1], tag[3])
|
||||||
m += 1
|
m += 1
|
||||||
|
|
||||||
|
|
||||||
for ln, line in enumerate(article_bottom.rsplit('\n')):
|
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||||
# Paragraphs
|
# Paragraphs
|
||||||
# Open tag
|
# Open tag
|
||||||
|
if db.stat_paragraphs > 0:
|
||||||
if line.startswith(tyto.words_tags[10][0]):
|
if line.startswith(tyto.words_tags[10][0]):
|
||||||
set_css = tyto.get_css(line)
|
set_css = tyto.get_css(line)
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(post_bottom.rsplit('\n')[ln],
|
||||||
article_bottom.rsplit('\n')[ln],
|
|
||||||
tyto.words_tags[10][2]%set_css
|
tyto.words_tags[10][2]%set_css
|
||||||
)
|
)
|
||||||
# Close tag
|
# Close tag
|
||||||
elif line.startswith(tyto.words_tags[10][1]):
|
elif line.startswith(tyto.words_tags[10][1]):
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(line,
|
||||||
line,
|
|
||||||
tyto.words_tags[10][3]
|
tyto.words_tags[10][3]
|
||||||
)
|
)
|
||||||
# Open anchors
|
# Open anchors
|
||||||
|
if db.stat_anchors == 0: continue
|
||||||
anchor_links = re.findall(r'>_(.+?):', line)
|
anchor_links = re.findall(r'>_(.+?):', line)
|
||||||
for item in anchor_links:
|
for item in anchor_links:
|
||||||
anchor_id = '%s%s:'%(tyto.words_tags[0][0], item)
|
anchor_id = '%s%s:'%(tyto.words_tags[0][0], item)
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(anchor_id,
|
||||||
anchor_id, tyto.words_tags[0][2]%item
|
tyto.words_tags[0][2]%item
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,27 +255,27 @@ def wip_words_tags():
|
||||||
# - file_%i #
|
# - file_%i #
|
||||||
#-----------------------#
|
#-----------------------#
|
||||||
def wip_links():
|
def wip_links():
|
||||||
global article_bottom
|
global post_bottom
|
||||||
|
|
||||||
# Doing files, first, becase of similar marker
|
# Doing files, first, becase of similar marker
|
||||||
if db.uniq_files > 0:
|
if db.uniq_files > 0:
|
||||||
for i in range(1, db.uniq_files + 1):
|
for i in range(1, db.uniq_files + 1):
|
||||||
file = 'db.file_%s'%i
|
file = 'db.file_%s'%i
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(eval(file)[0]+'+',
|
||||||
eval(file)[0]+'+', eval(file)[1]%('_blank')
|
eval(file)[1]%('_blank')
|
||||||
)
|
)
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(eval(file)[0],
|
||||||
eval(file)[0], eval(file)[1]%('_self')
|
eval(file)[1]%('_self')
|
||||||
)
|
)
|
||||||
|
|
||||||
if db.uniq_links > 0:
|
if db.uniq_links > 0:
|
||||||
for i in range(1, db.uniq_links + 1):
|
for i in range(1, db.uniq_links + 1):
|
||||||
link = 'link_%s'%i
|
link = 'link_%s'%i
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(eval(link)[0]+'+',
|
||||||
eval(link)[0]+'+', eval(link)[1]%('_blank')
|
eval(link)[1]%('_blank')
|
||||||
)
|
)
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(eval(link)[0],
|
||||||
eval(link)[0], eval(link)[1]%('_self')
|
eval(link)[1]%('_self')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -278,12 +285,11 @@ def wip_links():
|
||||||
def wip_abbrs():
|
def wip_abbrs():
|
||||||
if db.uniq_abbrs == 0: return
|
if db.uniq_abbrs == 0: return
|
||||||
|
|
||||||
global article_bottom
|
global post_bottom
|
||||||
|
|
||||||
for i in range(1, db.uniq_abbrs + 1):
|
for i in range(1, db.uniq_abbrs + 1):
|
||||||
abbr = 'abbr_%s'%i
|
abbr = 'abbr_%s'%i
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(eval(abbr)[0],
|
||||||
eval(abbr)[0],
|
|
||||||
eval(abbr)[1]
|
eval(abbr)[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -304,12 +310,12 @@ def get_wh_image(value):
|
||||||
def wip_images():
|
def wip_images():
|
||||||
if db.uniq_images == 0: return
|
if db.uniq_images == 0: return
|
||||||
|
|
||||||
global article_bottom
|
global post_bottom
|
||||||
image_link = '<a class="%s" href="%s" title="%s">%s</a>'
|
image_link = '<a class="%s" href="%s" title="%s">%s</a>'
|
||||||
image_show = '<img class="%s" src="%s" alt="%s"%s />'
|
image_show = '<img class="%s" src="%s" alt="%s"%s />'
|
||||||
|
|
||||||
# Check each line
|
# Check each line
|
||||||
for ln, line in enumerate(article_bottom.rsplit('\n')):
|
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||||
# match line
|
# match line
|
||||||
if line.startswith('_image:'):
|
if line.startswith('_image:'):
|
||||||
values = line.rsplit(' ')
|
values = line.rsplit(' ')
|
||||||
|
@ -368,8 +374,8 @@ def wip_images():
|
||||||
# Set HTML to replace line number
|
# Set HTML to replace line number
|
||||||
image_html = image_tgt%image_src
|
image_html = image_tgt%image_src
|
||||||
|
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace(post_bottom.rsplit('\n')[ln],
|
||||||
article_bottom.rsplit('\n')[ln], image_html
|
image_html
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,10 +394,10 @@ def quote_params(qline):
|
||||||
def wip_quotes() :
|
def wip_quotes() :
|
||||||
if db.stat_quotes == 0: return
|
if db.stat_quotes == 0: return
|
||||||
|
|
||||||
global article_bottom
|
global post_bottom
|
||||||
global author, link, lang, book, date
|
global author, link, lang, book, date
|
||||||
|
|
||||||
for ln, line in enumerate(article_bottom.rsplit('\n')):
|
for ln, line in enumerate(post_bottom.rsplit('\n')):
|
||||||
# Decode from base64
|
# Decode from base64
|
||||||
if line.startswith('Q64'):
|
if line.startswith('Q64'):
|
||||||
line = line.replace('Q64.', '')
|
line = line.replace('Q64.', '')
|
||||||
|
@ -424,8 +430,8 @@ def wip_quotes() :
|
||||||
else: tab_c = tab_c + 2
|
else: tab_c = tab_c + 2
|
||||||
|
|
||||||
# Replace opened paragrph with html line
|
# Replace opened paragrph with html line
|
||||||
qline_html = '%s%s'%(
|
qline_html = '%s%s'%(tab_p * ' ',
|
||||||
tab_p * ' ', tyto.words_tags[10][2]%par_css
|
tyto.words_tags[10][2]%par_css
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add line to quote_html
|
# Add line to quote_html
|
||||||
|
@ -518,8 +524,8 @@ def wip_quotes() :
|
||||||
'</blockquote>'
|
'</blockquote>'
|
||||||
|
|
||||||
# Replace line with final HTML Quote
|
# Replace line with final HTML Quote
|
||||||
article_bottom = article_bottom.replace(
|
post_bottom = post_bottom.replace('Q64.%s.Q64'%line,
|
||||||
'Q64.%s.Q64'%line, quote_html
|
quote_html
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -530,13 +536,13 @@ def wip_quotes() :
|
||||||
def wip_icodes():
|
def wip_icodes():
|
||||||
if db.stat_icodes == 0: return
|
if db.stat_icodes == 0: return
|
||||||
|
|
||||||
global article_bottom
|
global post_bottom
|
||||||
|
|
||||||
matches = re.findall(r'I64.(.*?).I64', article_bottom)
|
matches = re.findall(r'I64.(.*?).I64', post_bottom)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
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)
|
post_bottom = post_bottom.replace(rep_icode, src_icode)
|
||||||
|
|
||||||
|
|
||||||
#==================================================#
|
#==================================================#
|
||||||
|
@ -546,9 +552,9 @@ def wip_icodes():
|
||||||
def wip_bcodes():
|
def wip_bcodes():
|
||||||
if db.stat_bcodes == 0: return
|
if db.stat_bcodes == 0: return
|
||||||
|
|
||||||
global article_bottom
|
global post_bottom
|
||||||
|
|
||||||
matches = re.findall(r'B64.(.*?).B64', article_bottom)
|
matches = re.findall(r'B64.(.*?).B64', post_bottom)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
rep_bcode = 'B64.' + match + '.B64'
|
rep_bcode = 'B64.' + match + '.B64'
|
||||||
src_bcode = tyto.b64("Decode", match, 'B64.', '.B64')
|
src_bcode = tyto.b64("Decode", match, 'B64.', '.B64')
|
||||||
|
@ -566,9 +572,11 @@ def wip_bcodes():
|
||||||
'</pre>'
|
'</pre>'
|
||||||
# Block-code content per line
|
# Block-code content per line
|
||||||
else:
|
else:
|
||||||
html_bcode = '%s\n <span class="bcode">%s</span>'%(html_bcode, line)
|
html_bcode = '%s\n <span class="bcode">%s</span>'%(html_bcode,
|
||||||
|
line
|
||||||
|
)
|
||||||
|
|
||||||
article_bottom = article_bottom.replace(rep_bcode, html_bcode)
|
post_bottom = post_bottom.replace(rep_bcode, html_bcode)
|
||||||
|
|
||||||
|
|
||||||
#========================================#
|
#========================================#
|
||||||
|
@ -578,11 +586,11 @@ def wip_bcodes():
|
||||||
def wip_titles():
|
def wip_titles():
|
||||||
if db.stat_titles == 0: return
|
if db.stat_titles == 0: return
|
||||||
|
|
||||||
global article_bottom
|
global post_bottom
|
||||||
article_temp = article_bottom
|
article_temp = post_bottom
|
||||||
article_tmp2 = '' # Construct article, without empty lines
|
article_tmp2 = '' # Construct article, without empty lines
|
||||||
|
|
||||||
for line in article_bottom.rsplit('\n'):
|
for line in post_bottom.rsplit('\n'):
|
||||||
if line.startswith('#'):
|
if line.startswith('#'):
|
||||||
hx = line[1]
|
hx = line[1]
|
||||||
title_cont = line[2: len(line)].lstrip()
|
title_cont = line[2: len(line)].lstrip()
|
||||||
|
@ -635,7 +643,7 @@ def wip_titles():
|
||||||
article_temp = '%s\n</div>'%article_temp
|
article_temp = '%s\n</div>'%article_temp
|
||||||
|
|
||||||
# Replace article with new contents
|
# Replace article with new contents
|
||||||
article_bottom = article_temp
|
post_bottom = article_temp
|
||||||
|
|
||||||
|
|
||||||
#==============================================#
|
#==============================================#
|
||||||
|
@ -671,7 +679,7 @@ def wip_raws(target):
|
||||||
# Make HTML tabulations #
|
# Make HTML tabulations #
|
||||||
#-----------------------#
|
#-----------------------#
|
||||||
def wip_tabs():
|
def wip_tabs():
|
||||||
global article_bottom
|
global post_bottom
|
||||||
article_temp = ''
|
article_temp = ''
|
||||||
tab = tab_start = 6 # From <article> tag
|
tab = tab_start = 6 # From <article> tag
|
||||||
indiv = False
|
indiv = False
|
||||||
|
@ -685,7 +693,7 @@ def wip_tabs():
|
||||||
'6' : '16'
|
'6' : '16'
|
||||||
}
|
}
|
||||||
|
|
||||||
for line in article_bottom.rsplit('\n'):
|
for line in post_bottom.rsplit('\n'):
|
||||||
# Titles
|
# Titles
|
||||||
if line.startswith('<h'):
|
if line.startswith('<h'):
|
||||||
get_tab = line[2]
|
get_tab = line[2]
|
||||||
|
@ -712,5 +720,5 @@ def wip_tabs():
|
||||||
if not article_temp: article_temp = '%s%s'%(int(tab) * ' ', line)
|
if not article_temp: article_temp = '%s%s'%(int(tab) * ' ', line)
|
||||||
else: article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
|
else: article_temp = '%s\n%s%s'%(article_temp, int(tab) * ' ', line)
|
||||||
|
|
||||||
article_bottom = article_temp
|
post_bottom = article_temp
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue