kindle-web-annotations

1.0.2 • Public • Published

kindle-web-annotations

node.js library to parse an Amazon Kindle My Clippings.txt file and emit objects that use the W3C Web Annotation Vocabulary.

Usage

This library exports a constructor for a Transport stream to which you can write chunks of the 'My Clippings' format and it will emit out JSON objects that use the Web Annotation Vocabulary.

const { ClippingTextToWebAnnotation } = require('kindle-web-annotations')
const fileName = process.argv[2]
require('fs').createReadStream(fileName)
  .pipe(new ClippingTextToWebAnnotation)
  .on('data', annotation => console.log(JSON.stringify(annotation)))

You can also use it as a small CLI:

⚡ node . fixtures/correlate.txt | jq .
{
  "@context": [
    "http://www.w3.org/ns/anno.jsonld",
    {
      "title": "as:title",
      "author": "as:author"
    }
  ],
  "id": "urn:uuid:74d85b38-7493-4e27-9257-38c303557bc2",
  "type": "Annotation",
  "motivation": "commenting",
  "created": "2017-09-17T18:28:04.000Z",
  "target": {
    "source": {
      "type": "http://schema.org/CreativeWork",
      "title": "Relativity",
      "author": "Albert Einstein"
    },
    "selector": {
      "type": "TextQuoteSelector",
      "exact": "21-In What Respects are the Foundations of Classical Mechanics and of the Special Theory of Relativity Unsatisfactory?"
    }
  },
  "body": {
    "type": "TextualBody",
    "value": "How would I know!?"
  }
}

Thanks to

Readme

Keywords

none

Package Sidebar

Install

npm i kindle-web-annotations

Weekly Downloads

0

Version

1.0.2

License

ISC

Last publish

Collaborators

  • gobengo