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 🙏

© 2026 – Pkg Stats / Ryan Hefner

oreilly-highlight-parser

v1.0.0

Published

A library to parse the highlights export file from the O'Reilly Learning Platform.

Readme

O'Reilly Highlight Parser

A TypeScript library for parsing highlight exports from the O'Reilly Learning Platform.

Installation

Install via NPM:

npm install oreilly-highlight-parser

Usage

This library provides three parsers to extract highlights from an O'Reilly CSV file. The CSV must contain the following columns:

  • Book Title
  • Chapter Title
  • Date of Highlight
  • Book URL
  • Chapter URL
  • Annotation URL
  • Highlight
  • Color
  • Personal Note

Parsers

Synchronous Parsing (CsvSyncParser)

Reads the entire CSV file into an array.

import fs from 'fs';
import { CsvSyncParser } from 'oreilly-highlight-parser';

const csvContents = fs.readFileSync('path/to/highlights.csv', 'utf8');
const parser = new CsvSyncParser();

const highlights = parser.parse(csvContents);

console.log(highlights);

Example Output:

[
  {
    "bookTitle": "Title of the book",
    "chapterTitle": "Title of the chapter",
    "dateOfHighlight": "2024-11-27",
    "bookUrl": "https://example.com/book",
    "chapterUrl": "https://example.com/book/chapter",
    "annotationUrl": "https://example.com/book/chapter/annotation",
    "highlight": "Highlighted text",
    "color": "YELLOW",
    "personalNote": "Personal note"
  }
]

Callback-Based Parsing (CsvCallbackParser)

Reads highlights and calls a callback function with the parsed data.

import fs from 'fs';
import { CsvCallbackParser } from 'oreilly-highlight-parser';

const csvContents = fs.readFileSync('path/to/highlights.csv', 'utf8');
const parser = new CsvCallbackParser();

parser.parse(csvContents, (error, highlights) => {
  if (error) {
    console.error('Error parsing CSV:', error);
    return;
  }

  console.log(highlights);
});

Streaming Parsing (CsvStreamParser)

Processes highlights as a stream.

import fs from 'fs';
import { CsvStreamParser } from 'oreilly-highlight-parser';

const csvStream = fs.createReadStream('path/to/highlights.csv');
const parser = new CsvStreamParser();

csvStream.pipe(parser)
  .on('data', (highlight) => {
    console.log(highlight);
  })
  .on('error', (err) => {
    console.error('Error parsing CSV:', err);
  });

Formatters

JSON Formatter (JsonFormatter)

Converts parsed highlights into JSON.

import { JsonFormatter } from 'oreilly-highlight-parser';

const highlight = {
  bookTitle: 'Title of the book',
  chapterTitle: 'Title of the chapter',
  dateOfHighlight: 2024-11-27, // PlainDate
  bookUrl: 'https://example.com/book',
  chapterUrl: 'https://example.com/book/chapter',
  annotationUrl: 'https://example.com/book/chapter/annotation',
  highlight: 'Highlighted text',
  color: 'YELLOW',
  personalNote: 'Personal note',
};

const formatter = new JsonFormatter();
const json = formatter.transform(highlight);

console.log(json);

Example Output:

{
  "bookTitle": "Title of the book",
  "chapterTitle": "Title of the chapter",
  "dateOfHighlight": "2024-11-27",
  "bookUrl": "https://example.com/book",
  "chapterUrl": "https://example.com/book/chapter",
  "annotationUrl": "https://example.com/book/chapter/annotation",
  "highlight": "Highlighted text",
  "color": "YELLOW",
  "personalNote": "Personal note"
}

Markdown Formatter (MarkdownFormatter)

Formats highlights into a Markdown quote block.

import { MarkdownFormatter } from 'oreilly-highlight-parser';

const highlight = {
  bookTitle: 'Title of the book',
  chapterTitle: 'Title of the chapter',
  dateOfHighlight: 2024-11-27, // PlainDate
  bookUrl: 'https://example.com/book',
  chapterUrl: 'https://example.com/book/chapter',
  annotationUrl: 'https://example.com/book/chapter/annotation',
  highlight: 'Highlighted text',
  color: 'YELLOW',
  personalNote: 'Personal note',
};

const formatter = new MarkdownFormatter();
const markdown = formatter.transform(highlight);

console.log(markdown);

Example Output:

> Highlighted text
>
> - Chapter 1: Logic, [Essential Programming](https://example.com/book/chapter1#section)

Escaped Chapter Titles Starting with Numbers:

> Highlighted text
>
> - 1\. Logic, [Essential Programming](https://example.com/book/chapter1#section)

License

This library is licensed under the MIT License.