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

@macive/lesson-plan-parser

v1.0.0

Published

Robust, flexible DOCX lesson plan parser that converts structured lesson plans into clean, database-ready JSON.

Readme

Lesson Plan Parser

A robust, flexible TypeScript Node.js application that parses DOCX lesson plan documents into clean, structured JSON suitable for database seeding.

Features

  • DOCX-to-JSON conversion using mammoth for reliable text extraction
  • HTML intermediate parsing to preserve table structures (Core Competencies, Values, PCIs)
  • Flexible field extraction handles formatting variations across different curriculum files
  • Auto-fix engine repairs common DOCX extraction errors (concatenated lines, missing newlines, malformed headers)
  • Multi-lesson splitting accurately splits documents into individual lesson blocks
  • Fully typed with TypeScript interfaces for all parsed entities
  • CLI & programmatic API use via command line or import into your own code

Installation

npm install

Usage

CLI

# Parse single file
npx ts-node src/cli.ts path/to/lesson-plans.docx -o ./output

# Parse multiple files
npx ts-node src/cli.ts plan1.docx plan2.docx plan3.docx -o ./json-output

# With options
npx ts-node src/cli.ts plans.docx -o ./output --raw --pretty

CLI Options:

  • -o, --output <dir> — Output directory (default: ./output)
  • -r, --raw — Include raw extracted text in JSON
  • -p, --pretty — Pretty-print JSON output
  • -m, --min-length <n> — Minimum lesson block length filter

Programmatic API

import { parseDocxFile, parseDocxFiles } from "./index";

// Single file
const result = await parseDocxFile("path/to/plans.docx");
console.log(result.document?.lessons);

// Multiple files
const results = await parseDocxFiles([
  { filePath: "plan1.docx", outputPath: "out1.json" },
  { filePath: "plan2.docx", outputPath: "out2.json" },
]);

JSON Output Structure

{
  "metadata": {
    "sourceFile": "string",
    "term": 1,
    "level": "GRADE 8",
    "learningArea": "AGRICULTURE AND NUTRITION",
    "grade": "Grade 8"
  },
  "lessons": [
    {
      "weekLessonLabel": "WEEK 1: LESSON 1",
      "weekNumber": 1,
      "lessonNumber": "1",
      "isCombinedLesson": false,
      "strand": "Hygiene Practices",
      "subStrand": "Cleaning practices",
      "learningOutcomes": {
        "preamble": "By the end of the lesson, the learner should be able to:",
        "items": ["Identify appropriate procedures...", "Explain the routine...", "Appreciate a clean..."]
      },
      "keyInquiryQuestions": ["How can we...?"],
      "coreCompetencies": ["Learning to learn", "Digital literacy"],
      "values": ["Integrity", "Responsibility"],
      "pcis": ["Health promotion", "Safety"],
      "learningResources": ["Agriculture and Nutrition grade 8..."],
      "organizationOfLearning": {
        "introduction": { "duration": "5 minutes", "content": ["Review..."] },
        "lessonDevelopment": {
          "duration": "30 minutes",
          "steps": [
            { "stepNumber": 1, "title": "Daily Cleaning Practices", "content": ["Discuss..."] }
          ]
        },
        "conclusion": { "duration": "5 minutes", "content": ["Summarize..."] }
      },
      "extendedActivities": ["Conducting a kitchen cleaning..."],
      "teacherSelfEvaluation": ""
    }
  ]
}

Supported Document Variations

The parser is designed to be resilient against different formatting styles:

  • Header tables with varying column orders and empty cells
  • Spelling variations: "Organization" vs "Organisation", "Sub Strand" vs "Sub-Strand"
  • Key Inquiry Questions with optional (s) suffix
  • Numbered lists with various prefixes (1., 1.Define, 1**.**)
  • Combined lessons like WEEK 6: LESSON 1 - 2
  • Missing or empty teacher self-evaluation sections
  • Tables vs vertical lists for competencies/values/pcis
  • Malformed first lessons with concatenated fields

Project Structure

src/
  types/          # TypeScript interfaces
  extractors/     # DOCX text extraction
  parsers/        # Core parsing engine
  utils/          # Text normalization utilities
  index.ts        # Public API
  cli.ts          # CLI entry point

Building

npm run build

Compiled JavaScript will be in the dist/ directory.

License

MIT