Giter Club home page Giter Club logo

Comments (4)

philipwalton avatar philipwalton commented on September 27, 2024

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.

webpro avatar webpro commented on September 27, 2024

@nychng You could do that with an HTML validator (which you pass the original/source HTML as text).

from html-inspector.

keeganstreet avatar keeganstreet commented on September 27, 2024

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.

philipwalton avatar philipwalton commented on September 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.