Giter VIP home page Giter VIP logo

Comments (4)

glennjones avatar glennjones commented on July 23, 2024

Hi

Not sure why you would want to do this. Have you got a problem with the current DOM parsing?

The parseDom function structure comes from using https://github.com/cheeriojs/cheerio I picked this parser rather than https://github.com/tmpvar/jsdom because its was noticeable faster and handle more real world web pages without issue. Yes its more jQuery-like (which I do not like), but in tests it works faster with less issues. I think a lot of this is down to it using the more forgiving htmlparser2 code.

I would add that some of the architectural structure of microformat-node is based on a couple of generations of older JavaScript microformat parsers some browser based. So microformat-node could now be refactored into a more terse codebase and use modern JS patterns, but I think thats different from what you are suggesting?

If you could explain a little more what we would gain from the changes I could comment some more.

from microformat-node.

pyhedgehog avatar pyhedgehog commented on July 23, 2024

Problem 1: (why I want to add support for jsdom):

I already have a project using jsdom and want to add microfomat support.
I can't use cheerio because it doesn't provides DOM API (it's W3C standard at last).
I've not yet hit any page that jsdom can't parse.
I've not really tested parsing speed, but nowadays network still slower than CPU.

Problem 2: (why I mentioned function names):

Not even cheerio readme names their API a DOM. DOM means some specific API. So if some function has Dom in it's name somebody like me concludes that it accepts of produces objects that supports this specific API.

If you think that there are too match already-existing code that uses this particular function, I think that something like parseW3CDOM() would be clear for user. Is it sounds well for you?

from microformat-node.

pyhedgehog avatar pyhedgehog commented on July 23, 2024

I have an idea - load jQuery using jsdom and pass window.jQuery to parseDom(). What should be second argument (as jQuery has no $.root())? What else non-compatible functions of cheerio used?

from microformat-node.

glennjones avatar glennjones commented on July 23, 2024

Hi I have rebuilt the library still using cheerio, but is now based on the https://github.com/glennjones/microformat-shiv project. If you want to use jsdom I would I inject microformat-shiv and use its get method. This should work the same as using the current version of this project as they share most of the same code.

from microformat-node.

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.