From 359595d643e1ea8bd33961f6bc1d279635e80cab Mon Sep 17 00:00:00 2001 From: Cyrille LOUARN Date: Sun, 15 Oct 2023 01:59:45 +0200 Subject: [PATCH] [1.9.25] - new anchors process (HTML prepared at 'check') --- CHANGELOG.md | 4 + src/usr/bin/tyto | 4 +- .../program/__pycache__/check.cpython-311.pyc | Bin 35361 -> 38379 bytes .../program/__pycache__/debug.cpython-311.pyc | Bin 3905 -> 3905 bytes .../program/__pycache__/post.cpython-311.pyc | Bin 9250 -> 9500 bytes .../program/__pycache__/tools.cpython-311.pyc | Bin 7063 -> 7299 bytes .../program/__pycache__/wip.cpython-311.pyc | Bin 9003 -> 9003 bytes src/var/lib/tyto/program/check.py | 80 +++++++++++++++--- src/var/lib/tyto/program/debug.py | 2 +- src/var/lib/tyto/program/post.py | 7 ++ src/var/lib/tyto/program/tools.py | 8 +- src/var/lib/tyto/program/wip.py | 2 +- .../__pycache__/logs_fr.cpython-311.pyc | Bin 3129 -> 3179 bytes src/var/lib/tyto/translations/logs_fr.py | 5 +- 14 files changed, 95 insertions(+), 17 deletions(-) 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 5fd69792cd3ba0c163a6df869f8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!g<(#Av|AJP=~0=-*!v@ae(C)1XAYK&rlKb-r&cS+JJO^ZToP^gtQ>u^ z^xJDz=cI>|U;X%7X%>{II(+qE%r5`8W3dk|@nGuNW9f)wjy NEN4;p&(x0MKLNBegYf_W 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 1110be40f44b6ce69d42ad895b0a26c0ead73d5d..a2e9b0e78662548b8e95b1b74ee1b7bafa1a46c4 100644 GIT binary patch delta 30 kcmX>ocTkRdIWI340}!N0X>a5X`v3p{ delta 30 kcmX>ocTkRdIWI340}u$W)7r=#$jOqIlA5z>% 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 e4d963cb3ff6fcaffef991ee9e7025db6c6f9bde..ef8c192b5edbd4bbb6355e1fd81ffa90e3582af3 100644 GIT binary patch delta 584 zcmZ8cO>Yum5Z;#pF~F`XQVQjx%eGreDbQL!%d)jr6SRpYHD2bjU75F**wAF(J(#_8 zPaZtka3wJ@G5&xx@#0VL(35UB`3H>r1YZaTaVC?@GnwakW>mHljl4YT9~9n^Km8wtgXrGV{r0oN ze!lpDJo3L456N1RIhMmrhrV%4E^Ky@4O9Qk#!h}hc|pqJ%*Dg_Kc@_1Q^2UxKPok2 zU%5Tu#oqg$N^O#uPhSejU?FoUqyqo9nkMx?-u1*l&U^7de(c45Nlh<4x-v&Xqd9>{ Pqf|`}dx>${t6b+V#sQ-k delta 320 zcmY+8J5R!36o&bv8UwVVU~MVAShPqBDBcAxjCh%3F=u{1M+c3w4E_PqO*#GUP%e4-!=| zM>S-rj(J+g0&O5i4dk&18B0*0q7cl`CfB&mi`?P{H^<2qZ$MK=@5jVeoG^XDjDNeh z7HAtL?ZBd4E^~#eyny9Epgq{Mj}lg}3I}D_!89FUjhd)X3oaePqa#%57&STp>n1Ao zaL8^n|3iOfKmL_*?hlM7)(%h2OBQ}wUFNs#X6ijI$l|@b4EmyTwW VY${47m=xu`tkBDh=GKXC{{YD&Oy~dr 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 92ea0a9589ab09fe8ed530a5c95986921e9e85ec..96a389473a60ac558caba1646e9af6ee0091c1ba 100644 GIT binary patch delta 464 zcmbPk-fYRYoR^o20SL}>Xs5PHY~))eKKU#=CzA@}WCbyq$uR-~lV6Lc$rW&yuz*xS zKo&EMRm)Vvw18#uLuS!>mSv0#46A_{0*cg1xM6GthAcK1JB2lct%j)z$S>i8i2>y~ zVC)q36pj@3WkC7Wa6OC+HB7+_nw)+`l0aoe;vj+vNZewKe`x`vs|3{JWA*g()D<+G zgM+OUREsr3ill%Nnw&*)Aa!gx#U(|V1x4~84s&vG@hz_6lEk8t;_}Rrj3O(bXpuFD z0J-88b7@hgCi5+poXot`TP(SWMcG9alUGSdan%B4&jE39Cz|Pg4*OWIQ_#&I+6*kEa42&$UjCa|%TQVmwT@X=QP<&BDYpu%~j}0k19Cwsl zWOKQ~=5m3}WwN+r4r>$8%mw)@Cd-S-PL2@}nEYBiEwY%WgaxD$ z0FtUi>a826J}Df+dNx%0zUv^P6ovQ delta 28 icmZ4Ow%Uz*IWI340}u$W)7r@0C(LB0w0XAh1bzT(1_xsR 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 = (";;", "