test: suite completa di §11 e npm run verify verde

- html-validate su tutte le pagine; linkinator su astro preview (link, asset,
  CSS e ancore), con modalità --external per i siti esterni
- e2e Playwright: struttura e metadati di ogni pagina, 404, navigazione,
  sottomenu, menu mobile, ancore del vecchio sito, nessuna richiesta esterna,
  nessun cookie, localStorage vuoto, mappa solo dopo il clic, funzionamento
  senza JavaScript, modulo di contatto
- a11y: axe su tutte le pagine a 1440 e 390 px e negli stati interattivi,
  tastiera (skip link, sottomenu, menu mobile), focus visibile, testo al 200 %,
  reflow a 320 px, movimento ridotto
- check-compliance.mjs: P.IVA, link legali, risorse sicure, segnaposto,
  JSON-LD, sitemap, robots, .htaccess, badge e servizi, uso di
  «commercialista», riferimento L. 4/2013, budget
- fix: punti di interruzione in em, focus ciclico nel menu mobile,
  rel="noopener" sui link esterni del Markdown, numeri di telefono non spezzabili

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
This commit is contained in:
Claude committed 2026-10-15 22:55:46 +00:00
1 parent 8ce77de137
commit 601d13cfaf
40 files changed
+1798 -114

No files matched your search

+5
View File
@@ -18,6 +18,11 @@ export function telHref(phone: Phone): string {
return `tel:${phone.e164}`;
}
/** Numero da mostrare con spazi non separabili, così non va mai a capo. */
export function telText(phone: Phone | string): string {
return (typeof phone === 'string' ? phone : phone.display).replace(/ /g, '\u00a0');
}
export function mailtoHref(email: string, subject?: string): string {
return subject ? `mailto:${email}?subject=${encodeURIComponent(subject)}` : `mailto:${email}`;
}
+26
View File
@@ -0,0 +1,26 @@
/**
* Post-elaborazione dell'HTML generato dal Markdown.
*/
function hostOf(href: string): string | null {
try {
return new URL(href).host;
} catch {
return null;
}
}
/**
* Aggiunge `rel="noopener"` ai link verso altri siti (brief §4.7); i link si aprono nella stessa
* scheda. `siteHost` è l'host del sito (i link interni assoluti restano invariati).
*/
export function externalLinksNoopener(html: string, siteHost: string): string {
return html.replace(
/<a\s+href="(https?:\/\/[^"]+)"([^>]*)>/g,
(match, href: string, rest: string) => {
const host = hostOf(href);
if (!host || host === siteHost || /\brel=/.test(rest)) return match;
return `<a href="${href}" rel="noopener"${rest}>`;
},
);
}
+13 -7
View File
@@ -10,7 +10,7 @@
* restare nessun segnaposto.
*/
import { contactForm, denominazione, professionisti, sedePrincipale, studio } from '../data/studio';
import { addressLine, mailtoHref, telHref } from './format';
import { addressLine, mailtoHref, telHref, telText } from './format';
const esc = (s: string) =>
s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
@@ -44,7 +44,7 @@ function bloccoTitolare(): string {
const [k, ...v] = riga.split(': ');
rows.push(v.length ? [k, esc(v.join(': '))] : ['Note', esc(riga)]);
}
rows.push(['Telefono', `<a href="${esc(telHref(telefono))}">${esc(telefono.display)}</a>`]);
rows.push(['Telefono', `<a href="${esc(telHref(telefono))}">${esc(telText(telefono))}</a>`]);
rows.push(['E-mail', mailLink(studio.email)]);
if (pecStudio) rows.push(['PEC', mailLink(pecStudio.indirizzo)]);
return `<dl class="doc-card">${rows.map(([k, v]) => `<dt>${k}</dt><dd>${v}</dd>`).join('')}</dl>`;
@@ -77,7 +77,7 @@ function tokens(): Record<string, string> {
piva: esc(studio.partitaIva),
email: mailLink(studio.email),
pecStudio: mailLink(studio.pec[0].indirizzo),
telefono: `<a href="${esc(telHref(studio.telefoni[0]))}">${esc(studio.telefoni[0].display)}</a>`,
telefono: `<a href="${esc(telHref(studio.telefoni[0]))}">${esc(telText(studio.telefoni[0]))}</a>`,
fornitoreHosting: f.hosting
? `il fornitore del servizio di hosting (${esc(f.hosting)})`
: 'il fornitore del servizio di hosting',
@@ -96,6 +96,7 @@ function tokens(): Record<string, string> {
function conditions(): Record<string, boolean> {
return {
modulo: contactForm.mode !== 'off',
moduloPhp: contactForm.mode === 'php',
moduloEsterno: contactForm.mode === 'endpoint',
societa: datiSocietari().length > 0,
hosting: studio.fornitori.hosting !== null,
@@ -110,10 +111,15 @@ const COND = /<!--\s*se:(!?)([a-zA-Z]+)\s*-->([\s\S]*?)<!--\s*\/se:!?\2\s*-->/g;
export function renderLegal(html: string, source: string): string {
const conds = conditions();
const vals = tokens();
let out = html.replace(COND, (_m, neg: string, name: string, body: string) => {
if (!(name in conds)) throw new Error(`${source}: condizione sconosciuta «${name}»`);
return conds[name] !== (neg === '!') ? body : '';
});
// più passaggi: i blocchi condizionali possono essere annidati
let out = html;
for (let previous = ''; previous !== out;) {
previous = out;
out = out.replace(COND, (_m, neg: string, name: string, body: string) => {
if (!(name in conds)) throw new Error(`${source}: condizione sconosciuta «${name}»`);
return conds[name] !== (neg === '!') ? body : '';
});
}
out = out.replace(BLOCK_TOKEN, (_m, name: string) => vals[name]);
out = out.replace(TOKEN, (_m, name: string) => {
if (!(name in vals)) throw new Error(`${source}: segnaposto sconosciuto «{{${name}}}»`);