diff --git a/docs/assets/protocolith/concept_d.svg b/docs/assets/protocolith/concept_d.svg new file mode 100644 index 000000000..52efcf3ae --- /dev/null +++ b/docs/assets/protocolith/concept_d.svg @@ -0,0 +1 @@ +Protocolith mark, second iterationA faceted stone block with a P cut through it, an amber rule and a chain of five linked blocks whose last link, the ledger head, is filled. diff --git a/docs/assets/protocolith/logo-mark-v2-dark.svg b/docs/assets/protocolith/logo-mark-v2-dark.svg new file mode 100644 index 000000000..45ad6ecb6 --- /dev/null +++ b/docs/assets/protocolith/logo-mark-v2-dark.svg @@ -0,0 +1 @@ +Protocolith mark, second iterationA faceted stone block with a P cut through it, an amber rule and a chain of five linked blocks whose last link, the ledger head, is filled. diff --git a/docs/assets/protocolith/logo-mark-v2.svg b/docs/assets/protocolith/logo-mark-v2.svg new file mode 100644 index 000000000..52efcf3ae --- /dev/null +++ b/docs/assets/protocolith/logo-mark-v2.svg @@ -0,0 +1 @@ +Protocolith mark, second iterationA faceted stone block with a P cut through it, an amber rule and a chain of five linked blocks whose last link, the ledger head, is filled. diff --git a/docs/assets/protocolith/logo-v2-dark.svg b/docs/assets/protocolith/logo-v2-dark.svg new file mode 100644 index 000000000..b4c3d227e --- /dev/null +++ b/docs/assets/protocolith/logo-v2-dark.svg @@ -0,0 +1 @@ +Protocolith logoA faceted stone block with a P cut through it and a chain of five linked blocks whose last link is filled. Horizontal lockup with the Protocolith wordmark, for dark backgrounds. diff --git a/docs/assets/protocolith/logo-v2.svg b/docs/assets/protocolith/logo-v2.svg new file mode 100644 index 000000000..bb1062058 --- /dev/null +++ b/docs/assets/protocolith/logo-v2.svg @@ -0,0 +1 @@ +Protocolith logoA faceted stone block with a P cut through it and a chain of five linked blocks whose last link is filled. Horizontal lockup with the Protocolith wordmark, for light backgrounds. diff --git a/scripts/protocolith_run_esa_factory.py b/scripts/protocolith_run_esa_factory.py index 37991430d..0102e9829 100644 --- a/scripts/protocolith_run_esa_factory.py +++ b/scripts/protocolith_run_esa_factory.py @@ -72,8 +72,8 @@ def _write_json(path: Path, data: object) -> bytes: def _normalize_html(payload: bytes) -> str: text = payload.decode("utf-8", errors="replace") - text = re.sub(r"]*>.*?", " ", text, flags=re.I | re.S) - text = re.sub(r"]*>.*?", " ", text, flags=re.I | re.S) + text = re.sub(r"]*>.*?]*>", " ", text, flags=re.I | re.S) + text = re.sub(r"]*>.*?]*>", " ", text, flags=re.I | re.S) text = re.sub(r"<[^>]+>", " ", text) text = html.unescape(text) for before, after in { diff --git a/scripts/protocolith_run_leqembi_campaign.py b/scripts/protocolith_run_leqembi_campaign.py index 88a60d4a8..2629742f7 100644 --- a/scripts/protocolith_run_leqembi_campaign.py +++ b/scripts/protocolith_run_leqembi_campaign.py @@ -47,7 +47,7 @@ def sha(data: bytes) -> str: def normalized(data: bytes) -> str: text = data.decode("utf-8", "replace") - text = re.sub(r"]*>.*?|]*>.*?", " ", text, flags=re.I | re.S) + text = re.sub(r"]*>.*?]*>|]*>.*?]*>", " ", text, flags=re.I | re.S) text = html.unescape(re.sub(r"<[^>]+>", " ", text)) return re.sub(r"\s+", " ", text).strip() diff --git a/scripts/protocolith_run_nasa_factory.py b/scripts/protocolith_run_nasa_factory.py index bb17e9edb..e99f8c1da 100644 --- a/scripts/protocolith_run_nasa_factory.py +++ b/scripts/protocolith_run_nasa_factory.py @@ -72,8 +72,8 @@ def _write_json(path: Path, data: object) -> bytes: def _normalize_html(payload: bytes) -> str: text = payload.decode("utf-8", errors="replace") - text = re.sub(r"]*>.*?", " ", text, flags=re.I | re.S) - text = re.sub(r"]*>.*?", " ", text, flags=re.I | re.S) + text = re.sub(r"]*>.*?]*>", " ", text, flags=re.I | re.S) + text = re.sub(r"]*>.*?]*>", " ", text, flags=re.I | re.S) text = re.sub(r"<[^>]+>", " ", text) text = html.unescape(text) for before, after in { diff --git a/src/protocolith/core/issue.py b/src/protocolith/core/issue.py index 074059727..5a5045353 100644 --- a/src/protocolith/core/issue.py +++ b/src/protocolith/core/issue.py @@ -17,7 +17,13 @@ _MISSING_RE = re.compile(r"^missing (?:required |forecast |public claim )?field: (\w+)$") _MUST_INCLUDE_RE = re.compile(r"must include (\w+)$") -_XML_INVALID = re.compile("[\x00-\x08\x0b\x0c\x0e-\x1f\ufffe\uffff]") # not allowed in XML 1.0 documents +# Characters that are not allowed in XML 1.0 documents (listed as code points, not as a regular expression range). +_XML_INVALID = frozenset(map(chr, (*range(0x00, 0x09), 0x0B, 0x0C, *range(0x0E, 0x20), 0xFFFE, 0xFFFF))) + + +def _xml_safe(text: str) -> str: + """Replace the characters XML 1.0 cannot carry with U+FFFD.""" + return "".join("\ufffd" if ch in _XML_INVALID else ch for ch in text) def _missing_names(violations: list[str]) -> list[str]: @@ -94,5 +100,5 @@ def write_card_files(card: dict[str, Any], out_dir: Path) -> tuple[Path, Path]: raise InputError("CARD_EXISTS", f"{json_path.name} already exists with different content; use another --out") _atomic_write(json_path, payload) # Card text is user data and may hold characters XML 1.0 forbids; the JSON card keeps them verbatim. - _atomic_write(svg_path, _XML_INVALID.sub("\ufffd", render_svg(json_path)).encode("utf-8")) + _atomic_write(svg_path, _xml_safe(render_svg(json_path)).encode("utf-8")) return json_path, svg_path