diff --git a/CHANGELOG.md b/CHANGELOG.md index 755ab48..bec4f5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ Tyto - Littérateur # CURRENTLY IN DEV ! +## [1.9.25] +- fix typo when creating HTML list +- new anchors process (HTML prepared at 'check') + ## [1.9.24] - new list process (HTML prepared at 'check') diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index c3fef68..9371352 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Version: 1.9.24 -# Updated: 2023-10-14 1697296197 +# Version: 1.9.25 +# Updated: 2023-10-15 1697327876 # Tyto - Littérateur # Copyright (C) 2023 Cyrille Louarn diff --git a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc index 5fd6979..3c22155 100644 Binary files a/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/check.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc index 1110be4..a2e9b0e 100644 Binary files a/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/debug.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc index e4d963c..ef8c192 100644 Binary files a/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/post.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc index 92ea0a9..96a3894 100644 Binary files a/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/tools.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc index 131c6cf..2fc89ad 100644 Binary files a/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc and b/src/var/lib/tyto/program/__pycache__/wip.cpython-311.pyc differ diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 0cb6573..fd31051 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -137,6 +137,10 @@ def valid(target): post.error == 0 and sl_stags() \ or tools.exit(targets, post.error) + # Anchors links + post.error == 0 and anchors_links() \ + or tools.exit(targets, post.error) + # Quotes post.error == 0 and sl_ptags(post.ptags[1]) \ or tools.exit(targets, post.error) @@ -480,14 +484,6 @@ def is_value2_file_exists(ln, tag, val2): #=====================# # check text contents #======================================================== #=====================# -#=======================================# -# bcodes: first process ! # - - - -#---------------------------------------# - - #=========================================# # start line paired tags # # Generic check for all paired markers # @@ -697,6 +693,9 @@ def icodes(): # Return True/False # #----------------------------# def sl_stags(): + global anchors_ids + anchors_ids = () # Uniq anchors IDs + for ln, line in enumerate(texts, post.head_lines + 1): # legacy Tyto Titles if line.startswith(post.tyto_titles): @@ -705,7 +704,7 @@ def sl_stags(): debug.out(52, "%s. %s ?"%(ln, line), post.uri, True, 2, False) return False - # Avoic wanting #6 - #9 (but accept #1x.. #5x.. as comments...) + # Avoid wanting #6 - #9 (but accept #1x.. #5x.. as comments...) elif line[1].isdigit() and int(line[1]) >= 6: post.error = \ debug.out(52, "%s) %s..."%(ln, line[0:10]), post.uri, True, 1, False) @@ -723,10 +722,12 @@ def sl_stags(): html_val = post.html_titles[mark]%(css, title) post.cf_set("TITLES", html_var, html_val) + # Count Tyto Comments elif line.lstrip().startswith("#"): post.stats_tyto_text_coms += 1 - + + # Count HTML comments elif line.lstrip().startswith(post.text_comments): post.stats_html_coms += 1 @@ -752,9 +753,66 @@ def sl_stags(): post.cf_set("IMAGES", link_var, link_val) post.cf_set("IMAGES", html_var, html_val) + + # Anchor source + elif line.lstrip().startswith(post.anchor_target[0]): + anchor_id = tools.get_css(line, post.anchor_target[0]) + if anchor_id in anchors_ids: + post_error = \ + debug.out(54, '%s) "%s"'%(ln, anchor_id), post.uri, True, 2, False) + return False + anchors_ids = (*anchors_ids, anchor_id) + post.stats_text_anc_ids += 1 + + return True +#===========================# +# Find and anchors links # +# Check if anchor_id exists # +#---------------------------# +def anchors_links(): + markers = post.anchor_link + for ln, line in enumerate(texts, post.head_lines + 1): + anc_links = re.findall('%s(.*?)%s'%(markers[0], markers[1]), line) + if not anc_links: + continue + + for anc_link in anc_links: + if not ":" in anc_link: + debug.out(51, '%s) ">_id:%s_<"'%( + ln, langs.logs.anchor_title, + ), post.uri, True, 1, False) + continue + + anc_id = anc_link.rsplit(":")[0] + if anc_id in anchors_ids: + anc_title = anc_link.rsplit(":")[1].lstrip() + if not anc_title: + post.error = \ + debug.out(51, '%s) ">_%s:?_<"'%( + ln, anc_id + ), post.uri, True, 2, False) + return False + + # Set to post Database + post.stats_text_anc_links += 1 + post.cf_set("ANCHORS", + "anchor_%s"%post.stats_text_anc_links, + post.anchor_set[0]%anc_link + ) + post.cf_set("ANCHORS", + "html_%s"%post.stats_text_anc_links, + post.anchor_set[1]%(css, anc_id, anc_title) + ) + else: + post.error = \ + debug.out(51, '%s) "-> %s"'%(ln, anc_id), post.uri, True, 2, False) + return False + + return True + #================================# # Update post configuration file # #--------------------------------# @@ -822,6 +880,8 @@ def cf_update_values(): post.cf_set("STATS_TEXTS", "lines", str(post.text_lines)) post.cf_set("STATS_TEXTS", "tyto_coms", str(post.stats_tyto_text_coms)) post.cf_set("STATS_TEXTS", "html_coms", str(post.stats_html_coms)) + 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", "bcodes", str(post.ptags_stats["bcodes"])) post.cf_set("STATS_TEXTS", "bcodes_lines", str(post.stats_bcodes_lines)) diff --git a/src/var/lib/tyto/program/debug.py b/src/var/lib/tyto/program/debug.py index 48ef622..5e4fe7e 100644 --- a/src/var/lib/tyto/program/debug.py +++ b/src/var/lib/tyto/program/debug.py @@ -92,7 +92,7 @@ def out(nbr, var, val, show, color, stop): 51 : langs.logs.err_post_data, 52 : langs.logs.err_post_title, 53 : langs.logs.err_post_paired, - 54 : langs.logs.err_post_indent, + 54 : langs.logs.err_post_id_yet, 55 : langs.logs.err_post_in_tag, 56 : langs.logs.err_post_datatag, # WARNINGS (100-200) diff --git a/src/var/lib/tyto/program/post.py b/src/var/lib/tyto/program/post.py index 686e5a2..559ed72 100644 --- a/src/var/lib/tyto/program/post.py +++ b/src/var/lib/tyto/program/post.py @@ -262,6 +262,8 @@ stats_abbrs = 0 stats_total_files = 0 +stats_text_anc_ids = 0 +stats_text_anc_links = 0 stats_text_links = 0 stats_text_files = 0 stats_text_images = 0 @@ -340,6 +342,9 @@ html_titles = { html_brline = ("|", '
') html_hrline = ("--", '
') text_comments = (";;", "