diff --git a/src/imwald/core/author_html.py b/src/imwald/core/author_html.py index d9ee8cc..1c46999 100644 --- a/src/imwald/core/author_html.py +++ b/src/imwald/core/author_html.py @@ -72,7 +72,7 @@ def format_nip05_chips_html( container_margin_top: str | None = None, ) -> str: """ - Horizontal row of NIP-05 chips: favicon (per domain), identifier, verification mark. + Horizontal row of NIP-05 chips: identifier with domain favicon in place of ``@``, plus verification mark. ``bool | None``: ``True`` verified, ``False`` failed, ``None`` pending / not checked. """ @@ -81,13 +81,28 @@ def format_nip05_chips_html( parsed = parse_nip05_identifier(ident) dom = parsed[1] if parsed else "" fav = favicon_url_for_domain(dom) if dom else "" - esc = html.escape(ident, quote=False) + esc_full = html.escape(ident.strip(), quote=False) + esc_full_attr = html.escape(ident.strip(), quote=True) esc_fav = html.escape(fav, quote=True) if fav else "" - icon = "" - if fav: - icon = ( - f'' + raw = ident.strip() + at_split = raw.rpartition("@") if "@" in raw else ("", "", "") + local_raw, _at, dom_raw = at_split + id_body: str + if fav and local_raw and dom_raw: + esc_local = html.escape(local_raw, quote=False) + esc_dom = html.escape(dom_raw, quote=False) + id_body = ( + f'' + f'{esc_local}' + f'' + f'{esc_dom}' + f"" + ) + else: + id_body = ( + f'{esc_full}' ) if okv is True: mark = f'' @@ -104,15 +119,10 @@ def format_nip05_chips_html( ) else: wrap = ( - "display:inline-flex;align-items:center;gap:10px;padding:4px 4px 4px 0;" + "display:inline-flex;align-items:center;gap:8px;padding:4px 4px 4px 0;" "margin:0 16px 6px 0" ) - parts.append( - f'' - f"{icon}" - f'{esc}{mark}' - f"" - ) + parts.append(f'{id_body}{mark}') if not parts: return "" if container_margin_top is not None: