wip: links are converted to base64

This commit is contained in:
Cyrille L 2022-11-18 15:46:32 +01:00
parent 42bd5a40d8
commit fc47d177e2
2 changed files with 33 additions and 35 deletions

View File

@ -219,14 +219,14 @@ def check_article(post_uri, Force):
# Protect bCodes, keep markers for stats, before checking other markers
wip.convert_bcodes(article.rsplit('\n'),
'[[', ']]',
domain.domain_css)
'[[', ']]',
domain.domain_css)
article = wip.article_temp
# Protect quotes, keep markers for stats, before checking other markers
wip.convert_bcodes(article.rsplit('\n'),
'((', '))',
domain.domain_css)
'((', '))',
domain.domain_css)
article = wip.article_temp
# Protect iCodes, keep markers for stats
@ -304,13 +304,8 @@ def post_to_strings(post_uri):
post = True
continue
# In post content
if post:
article = '%s\n%s'%(article,line)
# In post header
else:
headers = '%s\n%s'%(headers,line)
if post: article = '%s\n%s'%(article,line) # In post content
else: headers = '%s\n%s'%(headers,line) # In post header
# Get number lines in headers, min line separator
headers_ln = len(headers.split("\n")) - 1
@ -601,7 +596,7 @@ def check_files(line, ln, stats_files_uniq):
else:
file_uri = '/%s'%(file_uri)
# Current or curstom URI
# Current or custom URI
else:
usr_file = '%s%s'%(domain.domain_articles,file_uri)
if not os.path.exists(usr_file):
@ -687,7 +682,7 @@ def check_images(line, ln, stats_images_uniq):
else:
image_uri = '/%s'%(image_uri)
# Current or curstom URI
# Current or custom URI
else:
usr_file = '%s%s'%(domain.domain_articles,image_uri)
if not os.path.exists(usr_file):

View File

@ -197,8 +197,9 @@ def wip_titles(wip_lines):
#================================================#
# Create Anchors (links) #
# Create Anchors (links) and convert to HTML #
# Target anchors are done with wip_begin_markers #
# Each are converted to Base64 #
#------------------------------------------------#
def wip_anchors(article):
global wip_html
@ -209,14 +210,16 @@ def wip_anchors(article):
for anchor in anchors_link:
anchor_id = anchor.rsplit(':',1)[0]
anchor_name = anchor.rsplit(':',1)[1]
article = article.replace('>_%s_<'%anchor,
anchor_fmt%(anchor_id, anchor_name)
)
wip_html = article
anchor_b64 = anchor_fmt%(anchor_id, anchor_name)
convert_to_b64(anchor_b64)
article = article.replace('>_%s_<'%anchor, b64_content)
#
# Convert links
#
wip_html = article
#==============================#
# Convert links to HTML #
# Each are converted to Base64 #
#------------------------------#
def wip_links(article):
global wip_html
@ -225,19 +228,20 @@ def wip_links(article):
for var in all_vars:
if var.startswith('link_'):
link = globals()[var]
article = article.replace('_%s'%link[0],
link_fmt%(
domain.domain_css, link[1],
link[2], link[0]
)
)
link = globals()[var]
link_b64 = link_fmt%(domain.domain_css, link[1],
link[2], link[0]
)
convert_to_b64(link_b64)
article = article.replace('_%s'%link[0], b64_content)
wip_html = article
#
#
#
#===========================================#
# Convert abbrs to HTML #
# each found are converted to Base64 #
# (avoid mismatch HTML if same word inside) #
#-------------------------------------------#
def wip_abbrs(article):
global wip_html
@ -246,11 +250,10 @@ def wip_abbrs(article):
for var in all_vars:
if var.startswith('abbr_'):
abbr = globals()[var]
abbr = globals()[var]
abbr_b64 = abbr_fmt%(domain.domain_css, abbr[1], abbr[2])
convert_to_b64(abbr_b64)
print('B64 for %s :> %s'%(abbr[1], b64_content))
article = article.replace(abbr[0], b64_content)
article = article.replace(abbr[0], b64_content)
wip_html = article