[1.9.26] - indented titles, prepared some words marks
This commit is contained in:
parent
359595d643
commit
3406954067
|
@ -9,6 +9,10 @@ Tyto - Littérateur
|
|||
|
||||
# CURRENTLY IN DEV !
|
||||
|
||||
## [1.9.26]
|
||||
- user can indent titles in text
|
||||
- prepared words markers (strong, bolds) (some to add soon)
|
||||
|
||||
## [1.9.25]
|
||||
- fix typo when creating HTML list
|
||||
- new anchors process (HTML prepared at 'check')
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
# Version: 1.9.25
|
||||
# Updated: 2023-10-15 1697327876
|
||||
# Version: 1.9.26
|
||||
# Updated: 2023-10-18 1697613100
|
||||
# Tyto - Littérateur
|
||||
|
||||
# Copyright (C) 2023 Cyrille Louarn <echolib+tyto@a-lec.org>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -149,6 +149,14 @@ def valid(target):
|
|||
post.error == 0 and sl_ptags(post.ptags[3]) \
|
||||
or tools.exit(targets, post.error)
|
||||
|
||||
# Paragraphs
|
||||
post.error == 0 and sl_ptags(post.ptags[2]) \
|
||||
or tools.exit(targets, post.error)
|
||||
|
||||
# divs
|
||||
post.error == 0 and sl_ptags(post.ptags[4]) \
|
||||
or tools.exit(targets, post.error)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -363,9 +371,6 @@ def ml_tag_values(ln, tag, stats):
|
|||
#-----------------------------------------------#
|
||||
# Convert values to HTML (put in post database) #
|
||||
#-----------------------------------------------#
|
||||
link_var = "%s_%s"%(tag.replace(":", ""), stats)
|
||||
html_var = "html_%s"%stats
|
||||
|
||||
# link:
|
||||
if tag == post.ml_tags[0]:
|
||||
section = "LINKS"
|
||||
|
@ -413,9 +418,6 @@ def ml_tag_values(ln, tag, stats):
|
|||
htmlbcode = "%s\n%s"%(htmlbcode, line)
|
||||
|
||||
html_value = tyto.code_bcode%(css, htmlbcode)
|
||||
#print()
|
||||
#print(html_value)
|
||||
#print()
|
||||
html_value = tools.b64_convert("encode", html_value)
|
||||
|
||||
# abbr:
|
||||
|
@ -426,8 +428,8 @@ def ml_tag_values(ln, tag, stats):
|
|||
css, value2, value3
|
||||
)
|
||||
|
||||
post.cf_set(section, link_var, tyto_value)
|
||||
post.cf_set(section, html_var, html_value)
|
||||
post.cf_set(section, "%s_%s"%(tag.replace(":", ""), stats), tyto_value)
|
||||
post.cf_set(section, "html_%s"%stats, html_value)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -521,7 +523,7 @@ def sl_ptags(markers):
|
|||
# at the same position
|
||||
if line.index(markers[0][0]) == index0:
|
||||
post.error = \
|
||||
debug.out(53, '%s: %s...%s) "%s"'%(
|
||||
debug.out(53, '%s: %s...%s) %s'%(
|
||||
markers[2], tag_ln, ln, markers[1]
|
||||
), post.uri, True, 2, False)
|
||||
return False
|
||||
|
@ -536,7 +538,7 @@ def sl_ptags(markers):
|
|||
if line.lstrip().startswith(markers[1]):
|
||||
if index0 < 0:
|
||||
post.error = \
|
||||
debug.out(53, '%s: %s) "%s"...'%(
|
||||
debug.out(53, '%s: %s) %s...'%(
|
||||
markers[2], ln, markers[0]
|
||||
), post.uri, True, 2, False)
|
||||
return False
|
||||
|
@ -548,20 +550,22 @@ def sl_ptags(markers):
|
|||
post.ptags_stats[markers[2]] += 1
|
||||
|
||||
# paragraphs don't need html wip yet
|
||||
if markers[2] == "parags":
|
||||
if markers[2] in ("parags", "divs"):
|
||||
continue
|
||||
|
||||
# Generic db Keys and values
|
||||
var_name = "%s_%s"%(markers[2][:-1], post.ptags_stats[markers[2]])
|
||||
val_raws = tools.b64_convert("encode", content)
|
||||
var_html = "html_%s"%post.ptags_stats[markers[2]]
|
||||
|
||||
# Specific values from marker
|
||||
val_html = tools.b64_convert("encode", convert[markers[2]](content))
|
||||
|
||||
# Set keys, values to post database
|
||||
post.cf_set(markers[2].upper(), var_name, val_raws)
|
||||
post.cf_set(markers[2].upper(), var_html, val_html)
|
||||
post.cf_set(
|
||||
markers[2].upper(),
|
||||
"%s_%s"%(markers[2][:-1], post.ptags_stats[markers[2]]),
|
||||
tools.b64_convert("encode", content)
|
||||
)
|
||||
post.cf_set(
|
||||
markers[2].upper(),
|
||||
"html_%s"%post.ptags_stats[markers[2]],
|
||||
tools.b64_convert("encode",
|
||||
convert[markers[2]](content)
|
||||
)
|
||||
)
|
||||
|
||||
# bcode not opened, but closed tag found
|
||||
elif index0 < 0:
|
||||
|
@ -571,21 +575,21 @@ def sl_ptags(markers):
|
|||
# ----------------------
|
||||
if index1 >= 0 and index0 < 0:
|
||||
post.error = \
|
||||
debug.out(53, '%s: %s) "%s"...'%(
|
||||
debug.out(53, '%s: %s) %s...'%(
|
||||
markers[2], tag_ln, markers[0]
|
||||
), post.uri, True,2, False)
|
||||
return False
|
||||
|
||||
if index0 >= 0 and index1 < 0:
|
||||
post.error = \
|
||||
debug.out(53, '%s: %s) ..."%s"'%(
|
||||
debug.out(53, '%s: %s) ...%s'%(
|
||||
markers[2], tag_ln, markers[1]
|
||||
), post.uri, True,2, False)
|
||||
return False
|
||||
|
||||
if index0 != index1:
|
||||
post.error = \
|
||||
debug.out(53, '%s: %s) "%s"..."%s"'%(
|
||||
debug.out(53, '%s: %s) %s...%s'%(
|
||||
markers[2], tag_ln, markers[0], markers[1]
|
||||
), post.uri, True,2, False)
|
||||
return False
|
||||
|
@ -620,7 +624,7 @@ def icodes():
|
|||
# First marker is a closed one
|
||||
if m1 < m0:
|
||||
post.error = \
|
||||
debug.out(53, '%s) "%s"..."%s"'%(
|
||||
debug.out(53, '%s) %s..."%s"'%(
|
||||
ln, markers[1][1], markers[1][0]
|
||||
), post.uri, True,2, False)
|
||||
return False
|
||||
|
@ -628,7 +632,7 @@ def icodes():
|
|||
# First marker but unused closed one
|
||||
if m0 >= 0 and m1 == -1:
|
||||
post.error = \
|
||||
debug.out(53, '%s) ..."%s"'%(
|
||||
debug.out(53, '%s) ...%s'%(
|
||||
ln, markers[1][1]
|
||||
), post.uri, True,2, False)
|
||||
return False
|
||||
|
@ -636,7 +640,7 @@ def icodes():
|
|||
# Last marker but unused opened one
|
||||
elif m1 >= 0 and m0 == -1:
|
||||
post.error = \
|
||||
debug.out(53, '%s) "%s"...'%(
|
||||
debug.out(53, '%s) %s...'%(
|
||||
ln, markers[1][0]
|
||||
), post.uri, True,2, False)
|
||||
return False
|
||||
|
@ -653,13 +657,17 @@ def icodes():
|
|||
line = line.replace(icnew, "")
|
||||
|
||||
# Set HTML [ICODES] to post database
|
||||
icode_var = "icode_%s"%post.stats_text_icodes
|
||||
icleg = markers[0][0] + icode + markers[0][1]
|
||||
html_var = "html_%s"%post.stats_text_icodes
|
||||
html_val = icnew.replace(markers[0][4], markers[0][2]%css)
|
||||
html_val = html_val.replace(markers[0][5], markers[0][3])
|
||||
post.cf_set("ICODES", icode_var, icleg)
|
||||
post.cf_set("ICODES", html_var, html_val)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"icode_%s"%post.stats_text_icodes,
|
||||
markers[0][0] + icode + markers[0][1]
|
||||
)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"html_%s"%post.stats_text_icodes,
|
||||
html_val.replace(markers[0][5], markers[0][3])
|
||||
)
|
||||
|
||||
# Single mark
|
||||
line = line.replace(markers[1][0], markers[1][4])
|
||||
|
@ -672,13 +680,17 @@ def icodes():
|
|||
line = line.replace(icnew, "")
|
||||
|
||||
# Set HTML [ICODES] to post database
|
||||
icode_var = "icode_%s"%post.stats_text_icodes
|
||||
icleg = markers[1][0] + icode + markers[1][1]
|
||||
html_var = "html_%s"%post.stats_text_icodes
|
||||
html_val = icnew.replace(markers[1][4], markers[1][2]%css)
|
||||
html_val = html_val.replace(markers[1][5], markers[1][3])
|
||||
post.cf_set("ICODES", icode_var, icleg)
|
||||
post.cf_set("ICODES", html_var, html_val)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"icode_%s"%post.stats_text_icodes,
|
||||
markers[1][0] + icode + markers[1][1]
|
||||
)
|
||||
post.cf_set(
|
||||
"ICODES",
|
||||
"html_%s"%post.stats_text_icodes,
|
||||
html_val.replace(markers[1][5], markers[1][3])
|
||||
)
|
||||
|
||||
texts[ln - 1 - post.head_lines] = line
|
||||
|
||||
|
@ -697,30 +709,34 @@ def sl_stags():
|
|||
anchors_ids = () # Uniq anchors IDs
|
||||
|
||||
for ln, line in enumerate(texts, post.head_lines + 1):
|
||||
linels = line.lstrip()
|
||||
|
||||
# legacy Tyto Titles
|
||||
if line.startswith(post.tyto_titles):
|
||||
if not line[3:]:
|
||||
if linels.startswith(post.tyto_titles):
|
||||
if not linels[3:]:
|
||||
post.error = \
|
||||
debug.out(52, "%s. %s ?"%(ln, line), post.uri, True, 2, False)
|
||||
debug.out(52, "%s) %s ?"%(ln, line), post.uri, True, 2, False)
|
||||
return False
|
||||
|
||||
# Avoid wanting #6 - #9 (but accept #1x.. #5x.. as comments...)
|
||||
elif line[1].isdigit() and int(line[1]) >= 6:
|
||||
elif linels[1].isdigit() and int(linels[1]) >= 6:
|
||||
post.error = \
|
||||
debug.out(52, "%s) %s..."%(ln, line[0:10]), post.uri, True, 1, False)
|
||||
debug.out(52, "%s) %s..."%(ln, linels[0:10]), post.uri, True, 1, False)
|
||||
return False
|
||||
|
||||
post.stats_titles += 1
|
||||
|
||||
# Create html value for this title in database
|
||||
link_var = "title_%s"%post.stats_titles
|
||||
post.cf_set("TITLES", link_var, line)
|
||||
|
||||
html_var = "html_%s"%post.stats_titles
|
||||
mark = line[0:2]
|
||||
title = line[3:]
|
||||
html_val = post.html_titles[mark]%(css, title)
|
||||
post.cf_set("TITLES", html_var, html_val)
|
||||
post.cf_set(
|
||||
"TITLES",
|
||||
"title_%s"%post.stats_titles,
|
||||
line
|
||||
)
|
||||
post.cf_set(
|
||||
"TITLES",
|
||||
"html_%s"%post.stats_titles,
|
||||
post.html_titles[linels[0:2]]%(css, line[3:])
|
||||
)
|
||||
|
||||
|
||||
# Count Tyto Comments
|
||||
|
@ -734,24 +750,34 @@ def sl_stags():
|
|||
# Convert tyto commented marker to HTML
|
||||
if line.lstrip().startswith(post.text_comments[0]):
|
||||
real_com = line.lstrip()[3:]
|
||||
link_var = "comm_%s"%post.stats_html_coms
|
||||
post.cf_set("COMMENTS", link_var, line.lstrip())
|
||||
html_var = "html_%s"%post.stats_html_coms
|
||||
post.cf_set("COMMENTS", html_var, '<!-- %s -->'%real_com)
|
||||
post.cf_set(
|
||||
"COMMENTS",
|
||||
"comm_%s"%post.stats_html_coms,
|
||||
line.lstrip()
|
||||
)
|
||||
post.cf_set(
|
||||
"COMMENTS",
|
||||
"html_%s"%post.stats_html_coms,
|
||||
'<!-- %s -->'%real_com
|
||||
)
|
||||
|
||||
|
||||
# Add stat + html for [IMAGES] when user wants to show logo in post
|
||||
elif line.lstrip().startswith("_image:logo"):
|
||||
post.stats_text_images += 1
|
||||
link_var = "image_%s"%(post.ml_tags_stats["image:"] + 1)
|
||||
link_val = "_image:logo"
|
||||
html_var = "html_%s"%(post.ml_tags_stats["image:"] + 1)
|
||||
html_val = tyto.image_link%(
|
||||
post.logo[1], "post_logo image", "%%s",
|
||||
post.title[1], post.title[1], "%%s"
|
||||
post.cf_set(
|
||||
"IMAGES",
|
||||
"image_%s"%(post.ml_tags_stats["image:"] + 1),
|
||||
"_image:logo"
|
||||
)
|
||||
post.cf_set(
|
||||
"IMAGES",
|
||||
"html_%s"%(post.ml_tags_stats["image:"] + 1),
|
||||
tyto.image_link%(
|
||||
post.logo[1], "post_logo image", "%%s",
|
||||
post.title[1], post.title[1], "%%s"
|
||||
)
|
||||
post.cf_set("IMAGES", link_var, link_val)
|
||||
post.cf_set("IMAGES", html_var, html_val)
|
||||
)
|
||||
|
||||
|
||||
# Anchor source
|
||||
|
@ -813,6 +839,17 @@ def anchors_links():
|
|||
|
||||
return True
|
||||
|
||||
|
||||
#=======================================
|
||||
# CHeck paired words marks #
|
||||
# Count for stats #
|
||||
# ! No neeed to create HTML in post db #
|
||||
#--------------------------------------#
|
||||
def words_tags():
|
||||
print("words_tags: soon...")
|
||||
|
||||
|
||||
|
||||
#================================#
|
||||
# Update post configuration file #
|
||||
#--------------------------------#
|
||||
|
@ -883,6 +920,8 @@ def cf_update_values():
|
|||
post.cf_set("STATS_TEXTS", "anc_targets", str(post.stats_text_anc_ids))
|
||||
post.cf_set("STATS_TEXTS", "anc_links", str(post.stats_text_anc_links))
|
||||
post.cf_set("STATS_TEXTS", "titles", str(post.stats_titles))
|
||||
post.cf_set("STATS_TEXTS", "parags", str(post.ptags_stats["parags"]))
|
||||
post.cf_set("STATS_TEXTS", "divs", str(post.ptags_stats["divs"]))
|
||||
post.cf_set("STATS_TEXTS", "bcodes", str(post.ptags_stats["bcodes"]))
|
||||
post.cf_set("STATS_TEXTS", "bcodes_lines", str(post.stats_bcodes_lines))
|
||||
post.cf_set("STATS_TEXTS", "quotes", str(post.ptags_stats["quotes"]))
|
||||
|
@ -896,6 +935,8 @@ def cf_update_values():
|
|||
post.cf_set("STATS_TEXTS", "codes", str(post.stats_text_codes))
|
||||
post.cf_set("STATS_TEXTS", "raws", str(post.stats_text_raws))
|
||||
|
||||
# ============================
|
||||
# Write new values in database
|
||||
# ============================
|
||||
post.cf_write()
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@ stats_bcodes_lines = 0
|
|||
stats_quotes = 0
|
||||
stats_parags = 0
|
||||
stats_lists = 0
|
||||
stats_divs = 0
|
||||
stats_links = 0
|
||||
stats_images = 0
|
||||
stats_files = 0
|
||||
|
@ -317,9 +318,10 @@ value2s_ext_uris = ("http", "ftp")
|
|||
# Paired markers
|
||||
ptags = (
|
||||
("{{", "}}", "bcodes"),
|
||||
("[[", "]]", "quotes"),
|
||||
('["', '"]', "quotes"),
|
||||
("((", "))", "parags", '<p class="%s">', "</p>"),
|
||||
("<<", ">>", "lists", "=", "+"),
|
||||
("<:", ":>", "lists", "=", "+"),
|
||||
("[[", "]]", "divs", '<div class="%s">', "</div>")
|
||||
)
|
||||
|
||||
ptags_stats = {
|
||||
|
@ -327,6 +329,7 @@ ptags_stats = {
|
|||
"quotes" : stats_quotes,
|
||||
"parags" : stats_parags,
|
||||
"lists" : stats_lists,
|
||||
"divs" : stats_divs,
|
||||
}
|
||||
|
||||
# Tyto Titles #1 = <h2>
|
||||
|
@ -345,9 +348,19 @@ text_comments = (";;", "<!--")
|
|||
anchor_target = ("->", '<a id="%s" class="anchor_target"></a>')
|
||||
anchor_link = (">_", "_<")
|
||||
anchor_set = (">_%s_<", '<a class="%s anchor_link" href="#%s">%s</a>')
|
||||
|
||||
quote_metas = ("cite:", "date:", "book:", "lang:", "link:")
|
||||
|
||||
# Words tags
|
||||
words_tags = (
|
||||
("*_", "_*", "strongs", '<strong class="%s">', '</strong>'),
|
||||
("+_", "_+", "bolds", '<b class="%s">', '</b>'),
|
||||
("[_", "_]", "cites", '<q class="%s">', '</q>'),
|
||||
(":_", "_:", "refs", '<cite class="%s">', '</cite>'),
|
||||
("~_", "_~", "dels", '<del class="%s">', '</del>'),
|
||||
("._", "_.", "underlines", '<u class="%s">', '</u>'),
|
||||
("/_", "_/", "emphasis", '<em class="%s">', '</em>'),
|
||||
)
|
||||
|
||||
# Specifics convertion
|
||||
words_markers = \
|
||||
(
|
||||
|
|
|
@ -137,7 +137,7 @@ def quote(lines):
|
|||
blockquote_lang = ' lang="%s"'%lang
|
||||
|
||||
# <footer> tag
|
||||
if book: footer_book = ' - %s'%book
|
||||
if book: footer_book = ' - <cite class="quote">%s</cite>'%book
|
||||
if cite: footer_cite = '-- %s'%cite
|
||||
if date:
|
||||
footer_date = ' (%s)'%date
|
||||
|
|
Loading…
Reference in New Issue