Validate a single extracted block and return its diagnostics with absolute
coordinates. Both syntax errors (severity error) and semantic warnings
(severity warning) are returned; consumers filter by severity as needed
(e.g. markdownlint surfaces only errors; remark/textlint add warnings in
strict mode). Suppression directives are honored — filtered in body-relative
coordinates before conversion — and broken body-scope directives are
reported via the suppression-* meta-rules.
File-scope (<!-- -->) directive diagnostics — both a broken directive and
one that suppressed nothing — are deliberately not reported here:
block.fileDirectives is the same array for every block in the document,
and this function runs once per block, so reporting them here would
duplicate the same diagnostic once per block. Worse for the unused case,
this function cannot even answer it: a file directive that fires in block 3
looks unused from block 1. lintMarkdown has the whole-document view and
reports both exactly once, at the directive's real document line, after
processing every block.
One consequence: callers that drive blockToDiagnostics per block and never
call lintMarkdown — today the CLI, remark, textlint, and the test-runner
adapters — surface no file-scope directive diagnostics at all. Reaching them
means giving each a document-level path (the CLI's --format json shape
nests every finding under a diagram and has no slot for a document-level
one), which is a separate change.
Validate a single extracted block and return its diagnostics with absolute coordinates. Both syntax errors (severity
error) and semantic warnings (severitywarning) are returned; consumers filter by severity as needed (e.g. markdownlint surfaces only errors; remark/textlint add warnings in strict mode). Suppression directives are honored — filtered in body-relative coordinates before conversion — and broken body-scope directives are reported via thesuppression-*meta-rules.File-scope (
<!-- -->) directive diagnostics — both a broken directive and one that suppressed nothing — are deliberately not reported here:block.fileDirectivesis the same array for every block in the document, and this function runs once per block, so reporting them here would duplicate the same diagnostic once per block. Worse for the unused case, this function cannot even answer it: a file directive that fires in block 3 looks unused from block 1.lintMarkdownhas the whole-document view and reports both exactly once, at the directive's real document line, after processing every block.One consequence: callers that drive
blockToDiagnosticsper block and never calllintMarkdown— today the CLI, remark, textlint, and the test-runner adapters — surface no file-scope directive diagnostics at all. Reaching them means giving each a document-level path (the CLI's--format jsonshape nests every finding under a diagram and has no slot for a document-level one), which is a separate change.