Mappa figure-pagine: link mancanti, Fig. 41 in dpp-1, sezione 'Pagine che la usano' nelle note e controlli 9-10 in lint
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aa9b943450
commit
eb672dfcd8
105 files changed
+361
-20
No files matched your search
@@ -9,6 +9,26 @@ out = root / "wiki/figures"
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
# --- pagine della wiki che usano ciascuna figura (link [[fig-...]] o embed del file), per la navigazione inversa ---
|
||||
import re as _re0
|
||||
_file2id = {pn["file"][:-4]: f["id"] for k in ("figures",) for f in cat[k] for pn in f["panels"]}
|
||||
_file2id.update({pn["file"][:-4]: f["id"] for f in cat.get("riassunto", {}).get("figures", []) for pn in f["panels"]})
|
||||
used_by = {}
|
||||
for _p in sorted((root / "wiki").rglob("*.md")):
|
||||
if "figures" in _p.parts or _p.name in ("figure-indice.md", "bibliografia.md"):
|
||||
continue
|
||||
_t = _p.read_text(encoding="utf8").split("---", 2)[-1]
|
||||
_ids = set(_re0.findall(r"\[\[((?:ris-)?fig-[\w-]+)", _t))
|
||||
_ids |= {_file2id[h] for h in _re0.findall(r"!\[\[immagini/([0-9a-f]{64})", _t) if h in _file2id}
|
||||
for _i in _ids:
|
||||
used_by.setdefault(_i, set()).add(_p.stem)
|
||||
|
||||
|
||||
def usage(fid):
|
||||
pages = sorted(used_by.get(fid, ()))
|
||||
return ["## Pagine che la usano", " · ".join(f"[[{x}]]" for x in pages) if pages else "nessuna", ""]
|
||||
|
||||
|
||||
def q(s):
|
||||
return json.dumps(str(s), ensure_ascii=False)
|
||||
|
||||
@@ -65,6 +85,7 @@ for f in cat["figures"]:
|
||||
body += ["## Da verificare", qual["review_notes"], ""]
|
||||
if v.get("issues"):
|
||||
body += ["Esito revisione indipendente: " + "; ".join(v["issues"]), ""]
|
||||
body += usage(f["id"])
|
||||
body += ["## Collegamenti", "- [[tesi]]", ""]
|
||||
(out / f"{f['id']}.md").write_text("\n".join(fm + body), encoding="utf8")
|
||||
|
||||
@@ -112,6 +133,7 @@ for f in ris:
|
||||
body += [f"- [[{e['id']}]] — {e['relation']} (verifica: {e['verified']})" for e in f["thesis_equivalents"]] + [""]
|
||||
if qual.get("review_notes"):
|
||||
body += ["## Da verificare", qual["review_notes"], ""]
|
||||
body += usage(f["id"])
|
||||
body += ["## Collegamenti", "- [[riassunto-tesi]] · [[riassunto-vs-tesi]]", ""]
|
||||
(out / f"{f['id']}.md").write_text("\n".join(fm + body), encoding="utf8")
|
||||
|
||||
|
||||
Reference in new issue
Block a user