npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sole/kindle-clippings-parser

v1.1.0

Published

Parsing Kindle's clippings files

Downloads

3

Readme

kindle-clippings-parser

A module to parse the clippings from a Kindle device.

This module only parses clippings. There's no pretty formatting or anything like that here.

If you want fancy formatting, you should try kindle-my-clippings, which does a lot more stuff and also offers a CLI, etc.

Shared for educational purposes. No support provided.

No Maintenance Intended

Installing

npm install @sole/kindle-clippings-parser

Using

var fs = require('fs');
var parse = require('@sole/kindle-clippings-parser').parse;

var fileContents = fs.readFileSync('clippings.txt', 'utf-8');
var parsed = parse(fileContents);

// You can do whatever you want with the data,
// but this is how you would iterate over it:
parsed.forEach(function(item) {
	// Each item is an object
	// { title, highlights }
	// item.highlights is an array of objects
	// item.highlights = [ { text, metadata }, { text, metadata }, ... ];
});

There's a working example in test/test.js that displays a bulleted list of highlights per title, using a sample test-clippings.txt file (also in the same test folder).

Limitations

This module assumes that everything is a highlight and ignores the fact that bookmarks are also saved in the clippings file. Bookmarks are interpreted as highlight, which does not make quite a lot of sense, but doesn't bother me right now.

Also metadata is not parsed either because I'm not interested in the location of the highlight or the time I created it.

There are also no proper tests. It might be the case that it doesn't work with certain types of clippings. The functions used for parsing are exposed in the module so they can be eventually be unit tested in the future. As a hobby project, it is highly unlikely this will happen though.

Where do you find the clippings file?

Assuming all Kindles work the same, connect it to your computer using a USB data cable (not all USB cables work for data... some are barely good for charging and that's it), and after a bit the device should appear in your file explorer (e.g. the Finder).

Open the device, navigate to the documents folder, and you'll find a file called My clippings.txt. Copy it to your computer and have fun!