v0.2.0
Targets specification v0.2 at conformance Level 1 — Core (§17.2). Rule ids are unchanged by the specification's renumbering (§15–18 became §16–19), so existing --ignore lists keep working.
What's new
- Templates (§15). Questions and their answers, placeholders tied to questions,
{{choose:}}, drafting notes (> [!DRAFTING]), insertion boundaries, and conditions on sections, list items, paragraphs, includes and attachments ({#id when=vat},when: forum:courts). - Alternatives and reference safety (§15.4). Declarations that can never appear together may share an identifier. Every
{{ref:}},{{term:}}and{{attach:}}must resolve under every combination of answers in which it is present. A unit whose condition can never hold is reported. - Final documents (§15.9).
legaldown validate --final(orvalidate_document(final=True)) reports blanks and template constructs left in a document meant for signature. - Automatic identifiers follow §5.3 exactly. NFKD normalization, the transliteration table, and collapsed hyphens:
Smluvní pokuta→smluvni-pokuta,Haftungsausschluß→haftungsausschluss. Identifiers that lose letters without an ASCII form, such as Cyrillic or CJK, are reported. - Parsing. Setext headings, fenced code blocks kept whole, the preamble before the first heading (§4.4), and directives lexed by the §11.2 grammar.
- New rules include
condition-invalid,condition-never-true,condition-reference-unsafe,question-unused,choose-invalid,drafting-note-def,drafting-note-unrecognized,insertion-boundary,placeholder-unfilled,template-construct-present,anchor-lossy-slug,def-lossy-slugandlegaldown-version-newer.
Breaking changes
Documents:
- Automatic identifiers change for headings and terms with accented or special Latin letters, runs of hyphens, or long numeric text. A
{{ref:}}written against the old identifier is nowref-broken. An automatic definition id with no usable text falls back tosection(wasterm). {{ref: a.b}}no longer resolves a section's dotted path, which §5.4 forbids.
Python API:
Section.identifierholds only an explicit{#id}. Generated identifiers are no longer written into the document; read them fromValidationResult.sections.Sectiongainscondition.- The serializer writes a heading marker only where the source had one, so generated identifiers stay generated.
DefinitionRef.section_identifieris replaced bysection_indexandfragment_index;DefinitionRefgainslossy_id.ensure_unique_identifierandDEF_ANCHOR_REare removed.slugify_identifierno longer takesfallback;generate_identifieralso returns whether letters were lost.Block.formatis removed.Metadata.supersedesisstr | Amends(it was a string holding a Python repr).Metadatagainslegaldown,questionsandnot_line_editable, andAttachmentgainswhen.
Conformance
Verified against the specification's fixtures corpus: 79 of the corpus's 113 rules are implemented, and every one the corpus exercises at Core level passes. Per §17.5, the rules not implemented are named in CONFORMANCE.md, with the known limits: include fragments, attachment files and amended originals are not read; nested lists are flattened (#16).
Install
pip install --upgrade legaldown-validator
Python 3.11+. Only dependency: PyYAML.