Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 2.54 KB

validate_export_html.md

File metadata and controls

60 lines (42 loc) · 2.54 KB

validate_export_html.py

Revision: 1 Last modified: 2026-12-04T18:36:44Z

Overview

Well-formedness checker for the exported .html siblings produced by scripts/testing/export_docs_formats.sh.

File SIZE does not prove an export is usable (§11.4.6). A generated sibling can be 1.1 MB and still be malformed markup — and a malformed export is not an export (§11.4.60), because the artefact would say something the source Markdown does not. The exporter's own check is a presence check ("non-empty, ends with </html>"), never a well-formedness check; this is the independent validator that closes that gap.

Prerequisites

  • python3 (standard library only).
  • The file(s) you pass must exist and be readable; unreadable input is a usage error (exit 2), never a pass.

Usage examples

python3 scripts/testing/validate_export_html.py docs/Issues.html
python3 scripts/testing/validate_export_html.py --quiet docs/*.html     # totals only
python3 scripts/testing/validate_export_html.py --self-test             # golden-good / golden-bad / negative control

Exit codes

code meaning
0 every input is well-formed
1 at least one input is malformed (the offending construct is named)
2 usage error or unreadable input
3 the --self-test failed

Edge cases

  • An empty file is malformed, not "vacuously fine".
  • --self-test carries a golden-good, a golden-bad and a negative control, because a checker that cannot be seen to fail is indistinguishable from one that always passes (§11.4.201(1)).
  • Bang-escaped or placeholder text that a Markdown source legitimately contains (e.g. <pid>) must be treated as text — that is the sibling script's job, not this one's; see escape_unknown_html_tags.py.

Internal behaviour

  1. Parses the argument list; validates that each input exists and is readable.
  2. Parses each document and reports unpaired tags, unclosed elements and stray special characters.
  3. Aggregates a per-file verdict and a total.
  4. --self-test runs the fixture set and asserts both polarities plus the negative control.

Related scripts

  • scripts/testing/escape_unknown_html_tags.py — escapes non-HTML placeholder tags BEFORE this check can see them.
  • scripts/testing/export_docs_formats.sh — the exporter whose output this validates.
  • scripts/gates/cm_docs_composite_sync.sh — the gate that demands the siblings exist and be current.

Last verified

2026-12-04 — python3 scripts/testing/validate_export_html.py --self-test → exit 0 on this repository.