Online W3C Validator
Pure Python command line for HTML validation using W3C online validator. It could be very handy for using it in a CI pipline.
Installation
pip install -U Online-W3C-Validator
How to use
You can user the CLI command:
w3c_validator http://www.google.com some_file.html
Example output:
INFO:w3c_validator.validator:Files to validate: http://www.google.com INFO:w3c_validator.validator:Number of files: 1 INFO:w3c_validator.validator:validating: http://www.google.com ... error: line 2: CSS: “display”: “inline-box” is not a “display” value in “inline-box” in “.ds”. error: line 2: The “bgcolor” attribute on the “body” element is obsolete. Use CSS instead. error: line 5: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.) error: line 5: Attribute “width” not allowed on element “div” at this point. error: line 5: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.) error: line 5: The “center” element is obsolete. Use CSS instead. error: line 5: The “clear” attribute on the “br” element is obsolete. Use CSS instead.
Or you can use the fuction validdate provied by the package, that thakes either HTML file name or URL as a single parameter an returns JSON object with the validation output.
from w3c_validator import validate
messages = validate("http://www.google.com")["messages"]
for m in messages:
print("Type: %(type)s, Line: %(lastLine)d, Description: %(message)s" % m)
Example output:
Type: error, Line: 2, Description: CSS: “display”: “inline-box” is not a “display” value in “inline-box” in “.ds”. Type: error, Line: 2, Description: The “bgcolor” attribute on the “body” element is obsolete. Use CSS instead. Type: error, Line: 5, Description: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.) Type: error, Line: 5, Description: Attribute “width” not allowed on element “div” at this point. Type: error, Line: 5, Description: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.) Type: error, Line: 5, Description: The “center” element is obsolete. Use CSS instead. Type: error, Line: 5, Description: The “clear” attribute on the “br” element is obsolete. Use CSS instead. Type: error, Line: 5, Description: The “align” attribute on the “div” element is obsolete. Use CSS instead. Type: error, Line: 5, Description: Attribute “nowrap” not allowed on element “div” at this point. ...
Contact
For bugs please use GitHub issues. For other matters feel free to contact me at nad2000@gmail.com.
Metadata
Release files for Online-W3C-Validator 0.3.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Online-W3C-Validator-0.3.21.tar.gz | 77.3 kB | Without provenance | Details for Online-W3C-Validator-0.3.21.tar.gz |
Release files / Online-W3C-Validator-0.3.21.tar.gz
| Download URL | Online-W3C-Validator-0.3.21.tar.gz |
|---|---|
| Size | 77.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d7eea3f78bca1ea1d2969d4cdd9ccf8c47de59b0a9548c7e07765852eab62dd
|
|
BLAKE2b-256 checksum How to use checksums |
fed3b87cbacf95abdcb4b1912eefad666aade4632620d643c5d15970492ee944
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for Online-W3C-Validator 0.3.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.