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

@ -304,13 +304,8 @@ def post_to_strings(post_uri):
post = True post = True
continue continue
# In post content if post: article = '%s\n%s'%(article,line) # In post content
if post: else: headers = '%s\n%s'%(headers,line) # In post header
article = '%s\n%s'%(article,line)
# In post header
else:
headers = '%s\n%s'%(headers,line)
# Get number lines in headers, min line separator # Get number lines in headers, min line separator
headers_ln = len(headers.split("\n")) - 1 headers_ln = len(headers.split("\n")) - 1
@ -601,7 +596,7 @@ def check_files(line, ln, stats_files_uniq):
else: else:
file_uri = '/%s'%(file_uri) file_uri = '/%s'%(file_uri)
# Current or curstom URI # Current or custom URI
else: else:
usr_file = '%s%s'%(domain.domain_articles,file_uri) usr_file = '%s%s'%(domain.domain_articles,file_uri)
if not os.path.exists(usr_file): if not os.path.exists(usr_file):
@ -687,7 +682,7 @@ def check_images(line, ln, stats_images_uniq):
else: else:
image_uri = '/%s'%(image_uri) image_uri = '/%s'%(image_uri)
# Current or curstom URI # Current or custom URI
else: else:
usr_file = '%s%s'%(domain.domain_articles,image_uri) usr_file = '%s%s'%(domain.domain_articles,image_uri)
if not os.path.exists(usr_file): 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 # # Target anchors are done with wip_begin_markers #
# Each are converted to Base64 #
#------------------------------------------------# #------------------------------------------------#
def wip_anchors(article): def wip_anchors(article):
global wip_html global wip_html
@ -209,14 +210,16 @@ def wip_anchors(article):
for anchor in anchors_link: for anchor in anchors_link:
anchor_id = anchor.rsplit(':',1)[0] anchor_id = anchor.rsplit(':',1)[0]
anchor_name = anchor.rsplit(':',1)[1] anchor_name = anchor.rsplit(':',1)[1]
article = article.replace('>_%s_<'%anchor, anchor_b64 = anchor_fmt%(anchor_id, anchor_name)
anchor_fmt%(anchor_id, anchor_name) convert_to_b64(anchor_b64)
) article = article.replace('>_%s_<'%anchor, b64_content)
wip_html = article wip_html = article
# #==============================#
# Convert links # Convert links to HTML #
# # Each are converted to Base64 #
#------------------------------#
def wip_links(article): def wip_links(article):
global wip_html global wip_html
@ -226,18 +229,19 @@ def wip_links(article):
for var in all_vars: for var in all_vars:
if var.startswith('link_'): if var.startswith('link_'):
link = globals()[var] link = globals()[var]
article = article.replace('_%s'%link[0], link_b64 = link_fmt%(domain.domain_css, link[1],
link_fmt%(
domain.domain_css, link[1],
link[2], link[0] link[2], link[0]
) )
) convert_to_b64(link_b64)
article = article.replace('_%s'%link[0], b64_content)
wip_html = article wip_html = article
# #===========================================#
# # Convert abbrs to HTML #
# # each found are converted to Base64 #
# (avoid mismatch HTML if same word inside) #
#-------------------------------------------#
def wip_abbrs(article): def wip_abbrs(article):
global wip_html global wip_html
@ -249,7 +253,6 @@ def wip_abbrs(article):
abbr = globals()[var] abbr = globals()[var]
abbr_b64 = abbr_fmt%(domain.domain_css, abbr[1], abbr[2]) abbr_b64 = abbr_fmt%(domain.domain_css, abbr[1], abbr[2])
convert_to_b64(abbr_b64) 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 wip_html = article