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 🙏

© 2025 – Pkg Stats / Ryan Hefner

hawaii-bill-diff

v1.0.1

Published

A specialized package for comparing Hawaii bill texts with advanced HTML parsing and content-based diffing capabilities

Readme

🏝️ Hawaii Bill Diff

A specialized npm package for comparing Hawaii bill texts with advanced HTML parsing and content-based diffing capabilities. This package is designed specifically for analyzing legislative changes in Hawaii bills, providing both line-by-line and content-based comparison views.

✨ Features

🔍 Advanced Bill Comparison

  • Content-Based Analysis: Compare bills by sections and subsections, not just lines
  • HTML Parsing: Extract and parse bill content from raw HTML sources
  • Formatting Detection: Identify changes in strikethrough, underline, and bold text
  • Section Mapping: Automatically detect and map bill sections (Section 1, Section 2, etc.)

📊 Multiple Comparison Views

  • Traditional Line-by-Line: Standard diff output showing added, removed, and modified lines
  • Content-Based Comparison: Section-by-section analysis with change categorization
  • Flowing Narrative: Continuous bill text with inline highlighting for changes
  • Detailed Analysis: Comprehensive breakdown of each section's changes

🎨 Visual Change Highlighting

  • Added Content: Green highlighting for new text
  • Removed Content: Red highlighting with strikethrough for deleted text
  • Modified Content: Yellow highlighting for changed text
  • Unchanged Content: Normal text display for consistent sections

🛠️ Technical Capabilities

  • LCS Algorithm: Longest Common Subsequence algorithm for intelligent text alignment
  • Word-Level Diffing: Precise identification of text changes at the word level
  • HTML Tag Preservation: Maintains formatting while extracting readable content
  • Section Parsing: Intelligent detection of bill structure and organization

🚀 Installation

npm install hawaii-bill-diff

📖 Usage

Basic HTML Comparison

import { compareBillContent, compareBillsFromHtml } from 'hawaii-bill-diff';

// Compare two HTML strings containing bill content
const html1 = '<body>Section 1. Purpose...</body>';
const html2 = '<body>Section 1. Purpose...</body>';

// Get content-based comparison
const contentDiff = compareBillContent(html1, html2);

// Get traditional line-by-line comparison
const lineDiff = await compareBillsFromHtml(html1, html2);

Content-Based Comparison Result

const result = compareBillContent(html1, html2);

console.log(result.summary);
// Output: { totalChanges: 3, addedSections: 1, removedSections: 1, modifiedSections: 1, unchangedSections: 2 }

console.log(result.sections);
// Output: Array of sections with change types: 'added', 'removed', 'modified', 'unchanged'

Parsing Bill Content

import { parseBillContent } from 'hawaii-bill-diff';

const parsedBill = parseBillContent(html);
console.log(parsedBill.sections);
// Output: Array of parsed sections with content and subsections

🔧 Example Application

The package includes a complete example application demonstrating all features:

# Clone the repository
git clone <repository-url>
cd hawaii-bill-diff

# Install dependencies
npm install

# Run the example app
npm run dev:example

Visit http://localhost:3000 to see the example application in action.

📋 API Reference

compareBillContent(html1: string, html2: string): ContentDiffResult

Performs content-based comparison between two HTML strings.

Returns:

interface ContentDiffResult {
  summary: {
    totalChanges: number;
    addedSections: number;
    removedSections: number;
    modifiedSections: number;
    unchangedSections: number;
  };
  sections: BillSection[];
}

compareBillsFromHtml(html1: string, html2: string): Promise<DiffResult>

Performs traditional line-by-line comparison between two HTML strings.

Returns:

interface DiffResult {
  added: string[];
  removed: string[];
  modified: string[];
  unchanged: string[];
  htmlChanges?: HtmlChange[];
}

parseBillContent(html: string): ParsedBillContent

Parses HTML content to extract bill structure and content.

Returns:

interface ParsedBillContent {
  title: string;
  content: string;
  sections: BillSection[];
  htmlElements: {
    strikethrough: string[];
    underline: string[];
    bold: string[];
  };
}

🎯 Use Cases

  • Legislative Analysis: Compare different versions of Hawaii bills
  • Policy Research: Track changes in proposed legislation
  • Legal Review: Identify modifications in bill text
  • Academic Research: Analyze legislative evolution
  • Public Transparency: Make bill changes easily understandable

🔍 How It Works

  1. HTML Parsing: Extracts bill content from raw HTML sources
  2. Section Detection: Identifies bill sections using pattern matching
  3. Content Extraction: Removes HTML tags while preserving formatting markers
  4. Text Alignment: Uses LCS algorithm to align similar content
  5. Change Detection: Identifies additions, deletions, and modifications
  6. Result Generation: Creates comprehensive comparison reports

🏗️ Architecture

The package is built with modern JavaScript/TypeScript and uses:

  • Vite: For fast builds and development
  • TypeScript: For type safety and better developer experience
  • LCS Algorithm: For intelligent text alignment
  • Regex Patterns: For HTML parsing and section detection

📝 License

ISC License

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📞 Support

For questions or issues, please open an issue on the GitHub repository.


Built specifically for Hawaii legislative analysis 🏛️