Skip to content

Heads-up: local validation rework in core pretext.py (integration notes) #1189

Description

@rbeezer

Local Validation: Integration Notes for pretext-CLI

2026-07-10. Covers PreTeXtBook/pretext#3004 (merged 2026-07-05) and
its refinements PreTeXtBook/pretext#3027 and PreTeXtBook/pretext#3028
(both merged 2026-07-10).

The library call

Core pretext.py (in-repo: pretext/lib/pretext.py):

validate(xml_source, pub_file, stringparams, out_file, dest_dir, method)

All arguments required and positional. method is one of:

method behavior
local jing (production pretext.rng) + validation-plus, one consolidated human-readable report
local-dev same, against the development schema pretext-dev.rng
terse same checks, machine-readable report (below)
server legacy round-trip to the validation server, unchanged

No return value; the products are files. Message counts go to the log.

Prerequisite: jing

The local methods run an installed jing. Callers must configure it
first; multi-token commands work:

common.set_executables({"jing": "jing"})
# or: {"jing": "java -jar /usr/share/java/jing.jar"}

Do not reach for lxml's RelaxNG instead: it cannot load pretext.rng
at all (externalRef, used for PreFigure), and with that patched away
it reports a tiny fraction of the problems, cryptically.

Products

Two files, named for the source, honoring the usual
out_file/dest_dir conventions: <basename>-validation.txt (the
report) and <basename>-assembled.xml deposited alongside it.
Validation examines the assembled "version" tree — xincludes merged,
version support applied — so pub_file matters, and message line
numbers refer to the deposited assembled file, never the author's
files. Only the file field points into author source. The report
ends without a trailing newline (awk counts lines right, wc -l is
one short).

The terse report

One message per line, five tab-separated fields:

file <TAB> path <TAB> line <TAB> check <TAB> message

path is a numbered path into the assembled source; every element
carries its count (/pretext[1]/article[1]/section[1]/image[1]), so
programs consume paths uniformly. (Only the human-readable report
squelches the count of an element with no like-named siblings.)
check is a stable kebab-case identifier of the validation-plus check
(tabular-ragged-rows, image-description-missing, ...); every
message from jing has check schema. Sorting on the fourth field
clusters occurrences of the same problem. pretext/pretext exposes
this as -V -M terse.

If you run validation-plus directly

The stylesheet's raw output changed in PreTeXtBook/pretext#3027: every
message now ends
with its bracketed identifier, e.g. ... will be missing from your LaTeX output [image-description-missing], in both multi-line and
single.line.output=yes forms. The id no-validation-message-id-assigned
signals a message added without one — worth a bug report.

Claude Fable 5, acting as a coding assistant for Rob Beezer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions