w3validator
v1.1.1
Published
W3C HTML validator for Node.js - validate HTML from URLs using W3C validator
Downloads
37
Maintainers
Readme
W3C HTML Validator for Node.js
Validate HTML code from your URLs using the W3C HTML validator. This package automatically checks your HTML pages using W3C's official validator.
🚀 Installation
Global Installation (recommended for CLI usage)
npm install -g w3validatorNow you can use the w3 command from anywhere!
Local Installation (for programmatic usage)
npm install w3validatornpx w3 /path/to/routeList.jsonTo uninstall:
npm uninstall -g w3validator📋 Features
- ✅ Uses official W3C validator
- 🔄 Automatic retry mechanism
- 📊 Detailed error reports
- 🎯 Multiple URL support
⚙️ Usage
CLI Usage
- First, create a routeList.json file. You can do this manually, or quickly generate a ready-to-use template by running the following command:
npx w3 create-templateThis command will create a file with the following structure:
{
"routeList": [
"http://example.com",
"http://example.com/about",
"http://example.com/contact"
]
}- After global installation, run from any directory:
w3 /path/to/routeList.jsonExample Route List File
{
"routeList": [
"http://127.0.0.1:8000/",
"http://127.0.0.1:8000/category1",
"http://127.0.0.1:8000/category2",
"http://127.0.0.1:8000/author",
"http://127.0.0.1:8000/search"
]
}📊 Output Example
[1/5] Validating: http://127.0.0.1:8000/
================================================================================
HTML fetched (15234 characters)
Validation attempt 1 started...
W3 validation completed successfully
=== VALIDATION RESULTS ===
[1] Error (error)
Message: Element "div" not allowed as child of element "span"
Location: Line 45:12 to Line 45:16
Extract: <span><div class="content">
---
[2] Warning (warning)
Message: Consider using the "h1" element as a top-level heading
Location: Line 120:5 to Line 120:9
Extract: <h2>Welcome</h2>
---
================================================================================
Validation completed for all routes!🛠️ Technologies
- TypeScript
- Node.js
- W3C HTML Validator
- JSDOM (HTML parsing)
- Vite (bundler)
