Skip to content

Convert Kindle Clippings to Objects that conform with W3C Web Annotation Vocabulary

Notifications You must be signed in to change notification settings

gobengo/kindle-web-annotations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

⚡ npx kindle-web-annotations | 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

About

Convert Kindle Clippings to Objects that conform with W3C Web Annotation Vocabulary

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published