Sublime Forum

Integration with a command line HTML/CSS validator


I have a new Linux and Mac command line (console) application/tool called htmlval (based on CSS HTML Validator for Windows) that validates HTML and CSS documents and spits out error and warning messages.

I want to tell users of htmlval how to best integrate it with various text editing programs and the first one I chose to try was Sublime Text.

So my question is, if a user is creating/editing an HTML or CSS documents with Sublime Text, then what is the best way they can use a command line tool like htmlval to check the document for errors and see the list of errors and warnings that htmlval produces. The input to htmlval would of course be the current document being edited in Sublime Text. The output can be a list of validation messages.

Ideally the user would be shown the validation messages and be able to click on one of the messages and be taken to the location of the error in the document. The tool (htmlval) can be configured to output the messages in various formats with line numbers and character locations.

Hopefully there is a good but simple solution. Not looking for a ‘complex’ solution at this point.

Albert Wiersch



After some “playing around”, what I have so far is here:

 "shell_cmd": "htmlval -ls --format \"%Type%%where%: %msgtext%\" \"${file}\""

It seems to work well, but is it possible to use a specific message format so that a user can click on a validator message in Sublime and Sublime will place the cursor at the proper location in the document where the error is?



1 Like


Thank you @jfcherng . This seems to be working well.

UPDATED 2023-02-08

 "shell_cmd": "htmlval -lhs --format \"%file%(%linenum%:%charnum%): %Type% - %msgtext%\" \"${file}\"",
 "file_regex": "^\\s*(\\S[^:]*)\\((\\d+):(\\d+)\\):\\s+([^\\n]+)"


@jfcherng, do you know if it’s possible for Sublime Text to capture an end line and end column, in order for messages to highlight a span of text in one or more lines?



Sorry I hardly use ST’s build system so I don’t know. But I think ST’s build system only supports annotation (which is only for one line) and phantom (which also only for one line).

1 Like