Skip to content

v0.2.0

Choose a tag to compare

@dvejsada dvejsada released this 23 Sep 17:41
2fef419

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 (or validate_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-slug and legaldown-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 now ref-broken. An automatic definition id with no usable text falls back to section (was term).
  • {{ref: a.b}} no longer resolves a section's dotted path, which §5.4 forbids.

Python API:

  • Section.identifier holds only an explicit {#id}. Generated identifiers are no longer written into the document; read them from ValidationResult.sections. Section gains condition.
  • The serializer writes a heading marker only where the source had one, so generated identifiers stay generated.
  • DefinitionRef.section_identifier is replaced by section_index and fragment_index; DefinitionRef gains lossy_id.
  • ensure_unique_identifier and DEF_ANCHOR_RE are removed. slugify_identifier no longer takes fallback; generate_identifier also returns whether letters were lost.
  • Block.format is removed. Metadata.supersedes is str | Amends (it was a string holding a Python repr). Metadata gains legaldown, questions and not_line_editable, and Attachment gains when.

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.