Comments (4)
Unfortunately this is not as easy as it looks.
Since HTML Inspector runs in the browser on live DOM, it's inspecting elements that have already been parsed and altered by the browser. That means that if the browser has corrected some of your unclosed tags, HTML Inspector sees them as properly closed.
The only way to actually validate raw markup from inside the browser would be to do an AJAX request for the content and parse the returned text yourself, which would be a lot of work and, at this point, is not something I'm planning on doing with HTML Inspector.
But who knows, maybe I'll change my mind in the future. Anyway, thanks for the suggestion.
from html-inspector.
@nychng You could do that with an HTML validator (which you pass the original/source HTML as text).
from html-inspector.
Hey @philipwalton,
I reckon I could help you implement this. As you said, the raw HTML could be accessed by sending an Ajax request to the URL of the current page.
I wouldn't go and reinvent the wheel by parsing the returned text, but instead POST it to http://validator.nu. I know from experience that validator.nu supports CORS, so we would be able to make the request from the page being tested and get a response. This would be similar to what I did in http://validator.keegan.st
We would probably then need to parse the errors returned from validator.nu and give the user a way to filter out the errors they don't care about. Again I would be able to leverage some of the code I wrote for validator.keegan.st
Do you think this would be useful?
Cheers
from html-inspector.
@keeganstreet I like this idea a lot. I actually had the same thought when I was pondering how to detect closing tags. But I'm worried it might introduce too much disconnect from HTML Inspector's current scope.
HTML Inspector's main selling point is it works on live DOM. That means it can check your HTML after your backbone views have been rendered and after your jQuery plugins have finished thrashing your initial DOM.
If we introduced pre-browser parsed validation, we'd either have to filter out most of those errors or live with duplicates. It would also not respect the config options like which node to start from or which subtrees to exclude, so that might introduce some confusion.
Anyway, I want to think about it a bit more before deciding against it, but those are my initial thoughts on the idea.
from html-inspector.
Related Issues (20)
- Warn CLI users if PhantomJS isn't installed. HOT 1
- Consider changing the executable name from `htmlinspector` to `html-inspector` for consistency. HOT 1
- NPM Error HOT 5
- ReferenceError: Can't find variable: HTMLInspector HOT 5
- Type error on Firefox 14.0.1 HOT 1
- Pure CSS stylesheets not found / classes not recognized HOT 3
- The <main> element can now appear more than once per page. HOT 3
- Link broken on FAQ HOT 1
- "PhantomJS must be installed to use the HTML Inspector CLI." (Windows 8.1) HOT 4
- Check for cross-domain errors in Firefox. HOT 1
- srcset bug HOT 1
- Don't analyse the content of scripts HOT 8
- "The span element cannot be a child of the del element." HOT 3
- adding a new rule
- disable save cache for url
- Action attribute really required on form elements?
- Please consider adding main to package.json HOT 1
- No output from html-inspector HOT 2
- "'autocomplete' is not a valid attribute of the <button> element."
- "<script> elements should appear right before the closing </body> tag for optimal performance."
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-inspector.