Skip to content
Margo dev

Purpose

check validates one document without producing HTML, PDF, or site files. Its --target value is html, site, pdf, or deck; the default is html. Target selection matters because a feature can be safe for an interactive page but unsuitable for a static or printable projection.

Input and output

Input is one Markdown path or - for stdin. Findings and the final error and warning counts go to stdout in text mode. JSON mode emits an object with diagnostics, errors, warnings, and an optional policy digest. Each finding can carry a source, line, column, field pointer, and remediation hint.

The JSON output contract is rendered directly from the versioned schema shipped with Margo:

Margo check report v1

The JSON envelope emitted by margo check --diagnostics json.

  • diagnostics array required

    All findings, including warnings, in source order.

    • *
      • code string required
        Constraints
        minLength=1
      • column integer
        Constraints
        minimum=1
      • hint string
      • line integer
        Constraints
        minimum=1
      • message string required
        Constraints
        minLength=1
      • pointer string
      • severity string
        Constraints
        enum=["info","warning","error"]
      • source string
  • errors integer required

    Number of error-severity findings.

    Constraints
    minimum=0
  • policy string

    SHA-256 identity of the trusted host policy when one was supplied.

  • warnings integer required

    Number of warning-severity findings.

    Constraints
    minimum=0

See the check report schema reference for the full tree and its other consumers.

Command failures that prevent a report go to stderr. See the CLI overview for shared input limits, policy rules, and stream behavior.

Raw HTML and iframe markup are denied by default. Pass --allow-unsafe-html when checking a trusted document that intentionally uses arbitrary HTML; the alias --allow-raw-html is equivalent.

Math

Use --math to check the same delimiters and source limits as compilation. When equations are present, check.math_runtime_validation_required explains that full expression and font validation happens in the browser or PDF export. An unmatched inline dollar remains text. See Math and LaTeX for examples and boundaries.

Examples

sh
margo check docs/guide.md --target html
margo check docs/guide.md --target pdf --diagnostics json \
  > build/check-pdf.json
cat docs/guide.md | margo check - --target deck

For --target site, ordinary relative Markdown links are accepted by the single-document check because the multi-page site build resolves and validates them after indexing all source documents. Other link diagnostics, such as an empty destination or an unsupported scheme, still apply to every target.

The CLI registers its chart checker automatically. Interactive Goshtoso Charts are valid for html, site, and standalone pdf; the deck target is a static projection for both HTML and PDF deck artifacts. Therefore margo check --target deck rejects renderer: interactive before rendering and points to /renderer; omit the field or set it to static.

Failures and diagnostics

Warnings remain visible but do not fail the command. Any error finding writes the complete report, then exits 1 with internal status check.failed.

Markdown table
CodeTypical correction
frontmatter.schema_invalidCorrect closed frontmatter fields and types
check.language_missingAdd a BCP 47 language value
check.image_alt_emptyAdd meaningful image alternative text
check.asset_missingRestore or correct a local image path
check.svg_incompatibleUse a supported static SVG
check.heading_level_skippedRestore a sequential heading outline
check.link_destination_emptyGive the link a destination
check.link_relativeReview target-specific relative-link behavior; ordinary site links are resolved by margo site
check.raw_htmlRemove raw HTML or supply trusted policy authority
check.math_runtime_validation_requiredPreview HTML or export PDF to validate expressions and bundled fonts
math.delimiter_unclosedClose the display block or math fence in its Markdown container
math.empty_expressionAdd an expression to the display block
mermaid.configuration_forbiddenRemove legacy Mermaid configuration
chart.renderer_target_unsupportedUse renderer: static for margo deck; use margo html, margo site, or margo pdf for interactive charts

Limitations and care

check does not prove that a Chromium executable can launch or export a PDF. Use doctor for discovery and run the real rendering command in the target environment. A single-document check is also not a complete multi-page site build with cross-page link and anchor validation.