<commit_before># microformat-node

A microformat parsing for node.js. 


## Install

    npm install microformat-node

or

    git clone http://github.com/glennjones/microformat-node.git
    cd microformat-node
    npm link


#### Use

with URL

    var shiv = require("microformat-node");

    shiv.parseUrl('http://glennjones.net/about', {}, function(data){
        // do something with data
    });


or with raw html

    var shiv = require('microformat-node');

    var html = '<p class="vcard"><a class="fn url" href="http://glennjones.net"><NAME></a></p>';
    shiv.parseHtml(html, {}, function(data){
        // do something with data
    });

with URL for a single format

    var shiv = require("microformat-node");

    shiv.parseUrl('http://glennjones.net/about', {'format': 'XFN'}, function(data){
        // do something with data
    });


#### Supported formats

Currently microformat-node supports the following formats: hCard, XFN, hReview, hCalendar, 
hAtom, hResume, geo, adr and tag. Its important to use the right case when specifying the format 
query string parameter.


#### Response 

This will return JSON. This is example of two geo microformats found in page.

    
    {
        "microformats": {
            "geo": [{
                "latitude": 37.77,
                "longitude": -122.41
            }, {
                "latitude": 37.77,
                "longitude": -122.41
            }]
        },
        "parser-information": {
            "name": "Microformat Shiv",
            "version": "0.2.4",
            "page-title": "geo 1 - extracting singular and paired values test",
            "time": "-140ms",
            "page-http-status": 200,
            "page-url": "http://ufxtract.com/testsuite/geo/geo1.htm"
        }
    }
    


#### Querying demo server.

Start the server binary:

    $ bin/microformat-node

Then visit the server URL

    http://localhost:8888/

#### Using the server API    

You need to provide the url of the web page use wish to parse and the format(s) you wish to parse 
as a single value or a comma delimited list: 


    GET http://localhost:8888/?url=http%3A%2F%2Fufxtract.com%2Ftestsuite%2Fhcard%2Fhcard1.htm&format=hCard

You can also use the hash # fragment element of a url to target an only part of a HTML page. 
The hash is used to target the HTML element with the same id. 

#### Viewing the unit tests

The module inculdes a page which runs the ufxtract microfomats unit test suite. 

    http://localhost:8888/unit-tests/


## Notes for Windows install.

microformat-node using a module called 'jsdom' which in turn uses 'contextify' that requires native code build.

There are a couple of things you normally need to do to compile node code on Windows.

1. Install python 2.6 or 2.7, the build scripts use it.
2. Run npm inside a Visual Studio shell, so for me,
     Start->Programs->Microsoft Visual Studio 2010->Visual Studio
Tools->Visual Studio Command Prompt

If you have the standard release of node it will probably be x86 rather
than x64, for x64 there is a different Visual Studio shell but usally in same
place.<commit_msg>Updated with contributors and license<commit_after># microformat-node

microformat-node is a microformat parser for node.js. It is built using a well tested light-weight JavaScript parsing engine, which already powers a number of browser extensions. It currently supports the following formats: hCard, XFN, hReview, hCalendar, hAtom, hResume, geo, adr and tag.


## Install

    npm install microformat-node

or

    git clone http://github.com/glennjones/microformat-node.git
    cd microformat-node
    npm link


#### Use

with URL

    var shiv = require("microformat-node");

    shiv.parseUrl('http://glennjones.net/about', {}, function(data){
        // do something with data
    });


or with raw html

    var shiv = require('microformat-node');

    var html = '<p class="vcard"><a class="fn url" href="http://glennjones.net"><NAME></a></p>';
    shiv.parseHtml(html, {}, function(data){
        // do something with data
    });

with URL for a single format

    var shiv = require("microformat-node");

    shiv.parseUrl('http://glennjones.net/about', {'format': 'XFN'}, function(data){
        // do something with data
    });


#### Supported formats

Currently microformat-node supports the following formats: hCard, XFN, hReview, hCalendar, hAtom, hResume, geo, adr and tag. It's important to use the right case when specifying the format query string parameter.


#### Response 

This will return JSON. This is an example of two geo microformats found in a page.

    
    {
        "microformats": {
            "geo": [{
                "latitude": 37.77,
                "longitude": -122.41
            }, {
                "latitude": 37.77,
                "longitude": -122.41
            }]
        },
        "parser-information": {
            "name": "Microformat Shiv",
            "version": "0.2.4",
            "page-title": "geo 1 - extracting singular and paired values test",
            "time": "-140ms",
            "page-http-status": 200,
            "page-url": "http://ufxtract.com/testsuite/geo/geo1.htm"
        }
    }
    


#### Querying demo server.

Start the server binary:

    $ bin/microformat-node

Then visit the server URL

    http://localhost:8888/

#### Using the server API    

You need to provide the url of the web page and the format(s) you wish to parse as a single value or a comma delimited list:


    GET http://localhost:8888/?url=http%3A%2F%2Fufxtract.com%2Ftestsuite%2Fhcard%2Fhcard1.htm&format=hCard

You can also use the hash # fragment element of a url to target only part of a HTML page. The hash is used to target the HTML element with the same id. 

#### Viewing the unit tests

The module inculdes a page which runs the ufxtract microfomats unit test suite. 

    http://localhost:8888/unit-tests/


## Notes for Windows install.

microformat-node using a module called 'jsdom' which in turn uses 'contextify' that requires native code build.

There are a couple of things you normally need to do to compile node code on Windows.

1. Install python 2.6 or 2.7, as the build scripts use it.
2. Run npm inside a Visual Studio shell, so for me,
     Start->Programs->Microsoft Visual Studio 2010->Visual Studio
Tools->Visual Studio Command Prompt

If you have the standard release of node it will probably be x86 rather
than x64, for x64 there is a different Visual Studio shell but usally in same
place.


## Support or Contact

Having trouble with microformat-node? Please raise an issue at: https://github.com/glennjones/microformat-node/issues

## Authors and Contributors

This project uses a refactored/rebuilt version of the Mozilla Operator Extension which Mozilla open sourced under the Mozilla Public License. It is currently maintained by <NAME>, but I would like to thank the authors and contributors of the original source code from which this project is derived. <NAME>, <NAME>, <NAME>, <NAME>, <NAME> and <NAME>.

## License

Portions created by <NAME> are Copyright (C) 2010-2012 <NAME>. All Rights Reserved. License under MPL, GPL and LGPL. See the license.txt file within the project source
{'fraction_non_alphanumeric': 0.10045788816428472, 'fraction_numerical': 0.018870542528097684, 'mean_word_length': 2.8504273504273505, 'pattern_counts': {'":': 26, '<': 22, '<?xml version=': 0, '>': 30, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2902616', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2030, 'n_words': 825}