Skip to content

--also-check-css reports HTML and SVG messages one line early #2166

Closed

Description

@ztatlock

Summary

With --also-check-css, the command-line checker reports every HTML and SVG message one line above its true line, so an error on line 1 is reported on line 0. CSS files in the same run report the right line.

URL for document that reproduces the problem

n/a

HTML/CSS/SVG snippet that reproduces the problem

n/a

Checker error messages

n/a

Spec links/citations

No response

Steps to reproduce

  1. Save this as test.html. The stray </b> is on line 4.

    <!doctype html>
    <html lang="en">
    <title>Test</title>
    </b>
  2. Run vnu --format gnu test.html.

  3. Run vnu --also-check-css --format gnu test.html.

Expected behavior

Both runs report the error on line 4.

Actual behavior

The second run reports it on line 3:

$ vnu --format gnu test.html
"file:/path/to/test.html":4.1-4.4: error: Stray end tag “b”.
$ vnu --also-check-css --format gnu test.html
"file:/path/to/test.html":3.1-3.4: error: Stray end tag “b”.

Every output format shows the same shift, as do stdin, URLs, and SVG files checked with --also-check-svg.

SimpleCommandLineValidator.setup() calls errorHandler.setLineOffset(-1) for the whole run whenever cssCheckingEnabled() is true. That cancels the newline in CSS_CHECKING_PROLOG, so it's right for a wrapped CSS document but wrong for everything else in the run. VerifierServletTransaction sets it only for text/css documents.

Two related things a fix may want to cover:

  • cssCheckingEnabled() leaves out skipNonCSS, so --skip-non-css gets no offset: an error on line 2 of a CSS file is reported on line 3.
  • SourceCode.setIsCss() is never undone, so a document checked after a CSS file in the same run keeps the CSS handling. Its messages get a wider extract, with hiliteStart 30 rather than 10.

A possible fix, which I haven't built or tested: have MessageEmitterAdapter, which already checks sourceCode.getIsCss() for columns, apply the -1 per document on the same check, drop the two setLineOffset(-1) calls, and clear isCss in checkAsHTML() and checkAsXML(). Setting the offset per file in SimpleCommandLineValidator wouldn't cover URLs, whose content type is only known inside checkHttpURL().

Seen with the latest release, 26.11.3 (93ef029).

Screenshots or screen recordings

No response

Activity

  1. sideshowbarker commented on Nov 4, 2026

    @sideshowbarker
    Member

    Thanks — all fixed now, and released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions