1.0.0 • Published 9 years ago

microdata-stream v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

microdata-stream

NPM

This module offers very basic microdata parsing.

TODO

  • support for itemref yet.
  • space separated attributes

Example

Running

var fs = require('fs')
var microdata = require('microdata-stream')

fs.createReadStream('example.html')
  .pipe(microdata())
  .on('data', function (data) {
    console.log(data)
  })

with

<section itemscope itemtype="http://schema.org/Person"> 
	Hello, my name is 
	<span itemprop="name">John Doe</span>, 
	I am a 
	<span itemprop="jobTitle">graduate research assistant</span> 
	at the 
	<span itemprop="affiliation">University of Dreams</span>. 
	My friends call me 
	<span itemprop="additionalName">Johnny</span>.
  <br/>
	You can visit my homepage at 
	<a href="http://www.JohnnyD.com" itemprop="url">www.JohnnyD.com</a>. 
	<section itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
		I live at 
		<span itemprop="streetAddress">1234 Peach Drive</span>,
		<span itemprop="addressLocality">Warner Robins</span>,
		<data itemprop="addressRegion" value="Georgia">ERROR</data>
	</section>
</section>

results in

{ itemscope: 'start' }
{ key: 'name' }
{ value: 'John Doe' }
{ key: 'jobTitle' }
{ value: 'graduate research assistant' }
{ key: 'affiliation' }
{ value: 'University of Dreams' }
{ key: 'additionalName' }
{ value: 'Johnny' }
{ key: 'url' }
{ value: 'http://www.JohnnyD.com' }
{ key: 'address' }
{ itemscope: 'start' }
{ key: 'streetAddress' }
{ value: '1234 Peach Drive' }
{ key: 'addressLocality' }
{ value: 'Warner Robins' }
{ key: 'addressRegion' }
{ value: 'Georgia' }
{ itemscope: 'end' }
{ itemscope: 'end' }