karlwestin / node-gumbo-parser

Parsing HTML in node using google's gumbo parser
MIT License
154 stars 12 forks source link

Using nan to support iojs #14

Closed mike820324 closed 9 years ago

mike820324 commented 9 years ago

This PR use nan to rewrite the code a bit. Now this module should support iojs.

karlwestin commented 9 years ago

Amazing! It seems to me we're losing 0.8 support but i think it's worth it to embrace the new :)

kkoopa commented 9 years ago

0.8 should still work, it is supported by NAN. Is there a compilation error? If so, there might be some additional tweaking necessary.

mike820324 commented 9 years ago

I'll check it out after I'm back to my office.

karlwestin commented 9 years ago

@kkoopa i haven't had time to look deeper into it, but this is what i get:

node-gumbo-parser (master)$ nvm use v0.8.28
Now using node v0.8.28
node-gumbo-parser (master)$ npm --version
1.2.30
node-gumbo-parser (master)$ npm install nan
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan
npm ERR! Error: No compatible version found: nan@'^1.7.0'
npm ERR! Valid install targets:
npm ERR! ["0.3.0-wip","0.3.0-wip2","0.3.0","0.3.1","0.3.2","0.4.0","0.4.1","0.4.2","0.4.3","0.4.4","0.5.0","0.5.1","0.5.2","0.6.0","0.7.0","0.7.1","0.8.0","1.0.0","1.1.0","1.1.1","1.1.2","1.2.0","1.3.0","1.4.0","1.4.1","1.5.0","1.4.2","1.4.3","1.5.1","1.5.2","1.6.0","1.5.3","1.6.1","1.6.2","1.7.0"]
npm ERR!     at installTargetsError (/Users/karl/.nvm/v0.8.28/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR!     at /Users/karl/.nvm/v0.8.28/lib/node_modules/npm/lib/cache.js:641:10
npm ERR!     at saved (/Users/karl/.nvm/v0.8.28/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:302:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 14.1.0
npm ERR! command "/Users/karl/.nvm/v0.8.28/bin/node" "/Users/karl/.nvm/v0.8.28/bin/npm" "install" "nan"
npm ERR! cwd /Users/karl/Development/node/node-gumbo-parser
npm ERR! node -v v0.8.28
npm ERR! npm -v 1.2.30
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/karl/Development/node/node-gumbo-parser/npm-debug.log
npm ERR! not ok code 0
node-gumbo-parser (master)$

removing the caret ("^") out of package.json just gave the same error on another module:

node-gumbo-parser (master)$ npm install
npm http GET https://registry.npmjs.org/node-gyp
npm http 304 https://registry.npmjs.org/node-gyp
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/fstream
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/npmlog
npm http GET https://registry.npmjs.org/osenv
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/tar
npm http GET https://registry.npmjs.org/semver
npm http GET https://registry.npmjs.org/which
npm http 200 https://registry.npmjs.org/mkdirp
npm http 200 https://registry.npmjs.org/fstream
npm http 200 https://registry.npmjs.org/glob
npm http 200 https://registry.npmjs.org/npmlog
npm http 200 https://registry.npmjs.org/osenv
npm http 200 https://registry.npmjs.org/minimatch
npm http 200 https://registry.npmjs.org/nopt
npm http 200 https://registry.npmjs.org/request
npm http 200 https://registry.npmjs.org/graceful-fs
npm http 200 https://registry.npmjs.org/semver
npm http 200 https://registry.npmjs.org/which
npm http 200 https://registry.npmjs.org/rimraf
npm http 200 https://registry.npmjs.org/tar
npm http GET https://registry.npmjs.org/ansi
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/minimist/0.0.8
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/inherits
npm ERR! Error: ENOENT, lstat '/Users/karl/Development/node/node-gumbo-parser/node_modules/node-gyp/node_modules/request/lib/getProxyFromURI.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 14.1.0
npm ERR! command "/Users/karl/.nvm/v0.8.28/bin/node" "/Users/karl/.nvm/v0.8.28/bin/npm" "install"
npm ERR! cwd /Users/karl/Development/node/node-gumbo-parser
npm ERR! node -v v0.8.28
npm ERR! npm -v 1.2.30
npm ERR! path /Users/karl/Development/node/node-gumbo-parser/node_modules/node-gyp/node_modules/request/lib/getProxyFromURI.js
npm ERR! fstream_path /Users/karl/Development/node/node-gumbo-parser/node_modules/node-gyp/node_modules/request/lib/getProxyFromURI.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /Users/karl/.nvm/v0.8.28/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:302:15)
npm ERR! Error: ENOENT, lstat '/Users/karl/Development/node/node-gumbo-parser/node_modules/node-gyp/node_modules/tar/test/pack.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 14.1.0
npm ERR! command "/Users/karl/.nvm/v0.8.28/bin/node" "/Users/karl/.nvm/v0.8.28/bin/npm" "install"
npm ERR! cwd /Users/karl/Development/node/node-gumbo-parser
npm ERR! node -v v0.8.28
npm ERR! npm -v 1.2.30
npm ERR! path /Users/karl/Development/node/node-gumbo-parser/node_modules/node-gyp/node_modules/tar/test/pack.js
npm ERR! fstream_path /Users/karl/Development/node/node-gumbo-parser/node_modules/node-gyp/node_modules/tar/test/pack.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /Users/karl/.nvm/v0.8.28/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:302:15)
npm ERR! Error: No compatible version found: glob@'^4.4.2'
npm ERR! Valid install targets:
npm ERR! ["1.1.0","2.0.9","2.0.8","2.0.7","2.1.0","3.0.0","3.0.1","3.1.0","3.1.1","3.1.2","3.1.3","3.1.4","3.1.5","3.1.6","3.1.7","3.1.9","3.1.10","3.1.11","3.1.12","3.1.13","3.1.14","3.1.15","3.1.16","3.1.17","3.1.18","3.1.19","3.1.20","3.1.21","3.2.0","3.2.1","3.2.3","3.2.4","3.2.5","3.2.6","3.2.7","3.2.8","3.2.9","3.2.10","3.2.11","4.0.0","4.0.1","4.0.2","4.0.3","4.0.4","4.0.5","4.0.6","4.1.2-beta","4.1.2","4.1.3","4.1.4","4.1.5","4.1.6","4.2.0","4.2.1","4.2.2","4.3.0","4.3.1","4.3.2","4.3.3","4.3.4","4.3.5","4.4.0","4.4.2","4.5.0","5.0.0"]
npm ERR!     at installTargetsError (/Users/karl/.nvm/v0.8.28/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR!     at /Users/karl/.nvm/v0.8.28/lib/node_modules/npm/lib/cache.js:641:10
npm ERR!     at RegClient.get_ (/Users/karl/.nvm/v0.8.28/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:101:14)
npm ERR!     at RegClient.<anonymous> (/Users/karl/.nvm/v0.8.28/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:37:12)
npm ERR!     at fs.readFile (fs.js:181:14)
npm ERR!     at Object.oncomplete (fs.js:302:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Darwin 14.1.0
npm ERR! command "/Users/karl/.nvm/v0.8.28/bin/node" "/Users/karl/.nvm/v0.8.28/bin/npm" "install"
npm ERR! cwd /Users/karl/Development/node/node-gumbo-parser
npm ERR! node -v v0.8.28
npm ERR! npm -v 1.2.30
npm http 200 https://registry.npmjs.org/minimist/0.0.8
npm http GET https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz
npm http 200 https://registry.npmjs.org/sigmund
npm http 200 https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz
npm http 200 https://registry.npmjs.org/inherits
npm http 200 https://registry.npmjs.org/inherits
npm http 200 https://registry.npmjs.org/lru-cache
npm http 200 https://registry.npmjs.org/abbrev
npm http 200 https://registry.npmjs.org/ansi
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/karl/Development/node/node-gumbo-parser/npm-debug.log
npm ERR! not ok code 0
kkoopa commented 9 years ago

Outdated npm.

On March 6, 2015 6:03:48 PM EET, MicroMike notifications@github.com wrote:

I'll check it out after I'm back to my office.


Reply to this email directly or view it on GitHub: https://github.com/karlwestin/node-gumbo-parser/pull/14#issuecomment-77583438

mike820324 commented 9 years ago

As @kkoopa said, if I update the npm to the latest version, it should install with no error, and test also passed.

 mike820324  ⋯  js  wating_for_merge  node-gumbo-parser  node --version
v0.8.28
 mike820324  ⋯  js  wating_for_merge  node-gumbo-parser  npm --version
2.7.0
 mike820324  ⋯  js  wating_for_merge  node-gumbo-parser  npm install
-
> gumbo-parser@0.1.11 install /Users/mike820324/ProgramProject/js/wating_for_merge/node-gumbo-parser
> node-gyp rebuild

  CC(target) Release/obj.target/gumbo/deps/gumbo-parser/src/attribute.o
../deps/gumbo-parser/src/attribute.c:30:21: warning: comparison of integers of different signs: 'int' and 'const unsigned int' [-Wsign-compare]
  for (int i = 0; i < attributes->length; ++i) {
                  ~ ^ ~~~~~~~~~~~~~~~~~~
1 warning generated.
  CC(target) Release/obj.target/gumbo/deps/gumbo-parser/src/char_ref.o
char_ref.rl:2492:12: warning: unused variable 'matched' [-Wunused-variable]
      bool matched = utf8iterator_maybe_consume_match(input, start, len, true);
           ^
...
compiling message...
...
1 warning generated.
  LIBTOOL-STATIC Release/libgumbo.a
  CXX(target) Release/obj.target/binding/node-gumbo.o
../node-gumbo.cc:65:10: warning: enumeration values 'GUMBO_NODE_DOCUMENT', 'GUMBO_NODE_ELEMENT', and 'GUMBO_NODE_COMMENT' not handled in switch [-Wswitch]
  switch(node->type) {
         ^
1 warning generated.
  SOLINK_MODULE(target) Release/binding.node
  SOLINK_MODULE(target) Release/binding.node: Finished
nan@1.7.0 node_modules/nan

node-gyp@0.10.10 node_modules/node-gyp
├── osenv@0.1.0
├── graceful-fs@2.0.3
├── which@1.0.9
├── semver@2.1.0
├── nopt@2.2.1 (abbrev@1.0.5)
├── fstream@0.1.31 (inherits@2.0.1, graceful-fs@3.0.5)
├── mkdirp@0.5.0 (minimist@0.0.8)
├── minimatch@0.4.0 (sigmund@1.0.0, lru-cache@2.5.0)
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
├── npmlog@0.1.1 (ansi@0.3.0)
├── tar@0.1.20 (inherits@2.0.1, block-stream@0.0.7)
├── rimraf@2.3.1 (glob@4.5.0)
└── request@2.53.0 (caseless@0.9.0, json-stringify-safe@5.0.0, forever-agent@0.5.2, aws-sign2@0.5.0, stringstream@0.0.4, oauth-sign@0.6.0, tunnel-agent@0.4.0, isstream@0.1.1, qs@2.3.3, node-uuid@1.4.3, combined-stream@0.0.7, http-signature@0.10.1, tough-cookie@0.12.1, mime-types@2.0.9, bl@0.9.4, hawk@2.3.1, form-data@0.2.0)
 mike820324  ⋯  js  wating_for_merge  node-gumbo-parser  npm run test

> gumbo-parser@0.1.11 test /Users/mike820324/ProgramProject/js/wating_for_merge/node-gumbo-parser
> node test/test.js

Running: normal
roots an object
Parses html tag
Parses head as a child of html
Parses attributes
...done!
Running: stopOnFirstError
stopped on error when option is passed
didn't stop on error by default
...done!
Running: legacy doctypes
added systemIdentifier and publicIdentifier
...done!
Running: unicode
Handles non-ascii characters
...done!
Running: custom tags
Handles custom tags
...done!
Running: fragment parsing
...done
karlwestin commented 9 years ago

alright, great! Thanks!