svenkreiss / html5validator

Command line tool to validate HTML5 files. Great for continuous integration.
MIT License
314 stars 34 forks source link

Make the json/xml output parseable by other tools #78

Closed php-coder closed 3 years ago

php-coder commented 3 years ago

The JSON/XML output can't be parsed by other tools (like jq) because it's invalid:

$ html5validator --root src/main/webapp/WEB-INF/views --format json 2>&1 | jq
parse error: Invalid numeric literal at line 1, column 6

Example of JSON output:

ERROR:html5validator.validator:['{"messages":[ ... ]}']

Example of XML output (it looks like XML within JSON):

ERROR:html5validator.validator:["<?xml version='1.0' encoding='utf-8'?>", '<messages xmlns="http://n.validator.nu/messages/">'

Another small improvement that would be nice to have, is to show output on stdout, so it can be piped to other utils. At this moment, I have to redirect stderr to stdout in order to process it:

$ html5validator --root src/main/webapp/WEB-INF/views --format json 2>&1 | less
svenkreiss commented 3 years ago

Thanks for reporting this. Maybe it's not solved all the way, but there is some progress towards this in #83.