P02 : une table du plan ne se coupe plus a son premier commentaire

_fusion_table traversait mal les commentaires interieurs a une entree :
chezlepro.ca (DNSSEC) etait coupee et ses enregistrements pris pour des entrees.
make verifier : CONFORME, 83 OK, 0 echec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Allaire 2026-09-28 13:17:52 -04:00
parent ffc171a2cb
commit 0156596f01
3 changed files with 75 additions and 3 deletions

View file

@ -1166,21 +1166,36 @@ def _fusion_table(bloc: list[str], entrees: dict) -> list[str]:
tete, corps = bloc[0], bloc[1:]
sortie, vues = [tete], set()
flow, colonne = 0, 0
# SEULS LES ENFANTS DIRECTS SONT DES ENTREES (2026-09-28). Une ligne plus indentee
# appartient a une entree ; la tester contre `_ENTREE_TABLE` la prenait pour une entree
# a part : ` - {nom: "@", type: A, ...}` donnait la clef `- {nom`, dont le YAML est
# une LISTE — et `.get` echouait (P02, depuis la zone signee du 2026-09-16).
enfant = next((m.group(1) for m in map(_ENTREE_TABLE.match, corps) if m), None)
i = 0
while i < len(corps):
ligne = corps[i]
m = _ENTREE_TABLE.match(ligne)
if not m:
if not m or m.group(1) != enfant:
sortie.append(ligne)
i += 1
continue
indent, cle, ecart, reste = m.group(1), m.group(2).strip(), m.group(3), m.group(4)
# L'entree s'etend sur les lignes PLUS indentees qui suivent immediatement.
# L'entree s'etend sur les lignes PLUS indentees qui suivent — Y COMPRIS a travers
# une ligne vide ou un commentaire, tant que la prochaine ligne SIGNIFICATIVE est
# encore plus indentee. S'arreter au premier commentaire coupait `chezlepro.ca:` en
# deux, a l'endroit ou il explique sa signature DNSSEC. Un commentaire suivi de
# l'entree SUIVANTE, lui, reste avec elle : il la coiffe.
fin = i
j = i + 1
while j < len(corps):
suite = corps[j]
if not suite.strip() or suite.strip().startswith("#"):
k = j + 1
while k < len(corps) and (not corps[k].strip() or corps[k].strip().startswith("#")):
k += 1
if k < len(corps) and len(corps[k]) - len(corps[k].lstrip()) > len(indent):
j = k
continue
break
creux = len(suite) - len(suite.lstrip())
if creux <= len(indent):