html-extract / hext

Domain-specific language for extracting structured data from HTML documents
https://hext.thomastrapp.com
Apache License 2.0
52 stars 3 forks source link

Node bindings and npm #6

Closed samatt closed 5 years ago

samatt commented 5 years ago

Hi,

First of thank you for this incredibly useful project. I was trying to use your node bindings and ran into some trouble. It seems that the NaN node module isn't supported in node v10 (which is what I need for a project). The issue I kept running into was similar to this. It totally worked on node v8.

I was just wondering if getting it to work in node v10 was something you were interested in/had time to work on. For now I will just install it as a CLI and spawn a process in node. Additionally, any plans to put this up on an NPM registry? I like cheerio but the ability to have html templates that i can use across languages is incredibly useful.

Thanks again,

Surya

thomastrapp commented 5 years ago

I will definitely try to fix the build for Node v10/v11 in the coming days.

any plans to put this up on an NPM registry?

Yes. It would be great if Hext was easily installable through npm, just like with pip. I will look into it in the next couple of weeks.

Thank you for the kind words!

thomastrapp commented 5 years ago

The Hext language bindings for Node are now compatible with nodejs v8, v10 and v11:

cd hext/libhext/bindings/nodejs
npm install
npm run build
# run tests
./test/blackbox.js.sh ../../../../test/case/*hext

@samatt Thank you for the bug report - Please let me know if there are more problems.

I will leave this issue open for the npm package.

samatt commented 5 years ago

omg that totally worked! thanks for your insanely fast response!

thomastrapp commented 5 years ago

Hext for Node is now installable through npm:

npm install hext

(Does not include the htmlext command-line utility).

Compatibility

https://www.npmjs.com/package/hext

Note: The Hext npm package starts at version 10. Earlier versions refer to a deprecated package of a previous owner. Npm's support is awesome and moved the package to my account.

Testing

An easy way to test an npm install is to run the following:

mkdir /tmp/hext-test
cd /tmp/hext-test
npm install hext
node -e 'require("hext")' && echo "hext loaded successfully"
git clone https://github.com/thomastrapp/hext.git
cd hext/test
cp ../libhext/bindings/nodejs/htmlext.js .
HTMLEXT="node htmlext.js" ./blackbox.sh case/*hext

@samatt I am closing this issue, but feel free to comment or open a new issue.

samatt commented 5 years ago

just writing to confirm npm install hext works! thanks again!