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

@bernierllc/content-transformer

v1.0.5

Published

Content format transformation utilities for markdown, HTML, and text processing

Readme

@bernierllc/content-transformer

Content format transformation utilities for markdown, HTML, and text processing with sanitization and metadata extraction.

Installation

npm install @bernierllc/content-transformer

Features

  • Multi-Format Support: Transform between markdown, HTML, and plain text
  • Format Detection: Automatically detect content format
  • HTML Sanitization: Built-in XSS protection with configurable allowed tags/attributes
  • Metadata Extraction: Extract word count, character count, and other metadata
  • Presets: Pre-configured transformation presets for common use cases
  • TypeScript Support: Full type safety with strict mode

Quick Start

Basic Usage

import { ContentTransformer, contentUtils } from '@bernierllc/content-transformer';

// Quick markdown to HTML
const html = await contentUtils.markdownToHtml('# Hello World');

// Quick HTML to markdown
const markdown = await contentUtils.htmlToMarkdown('<h1>Hello World</h1>');

// Extract plain text
const text = await contentUtils.toText('# Hello World', 'markdown');

// Sanitize HTML
const safe = await contentUtils.sanitizeHtml('<script>alert("xss")</script><p>Safe</p>');

Advanced Usage

import { ContentTransformer, transformationPresets } from '@bernierllc/content-transformer';

const transformer = new ContentTransformer();

// Transform with options
const result = await transformer.transform(markdown, {
  sourceFormat: 'markdown',
  targetFormat: 'html',
  sanitize: true,
  minify: false
});

// Use presets
const blogResult = await transformer.transform(
  markdown,
  transformationPresets.blogMarkdownToHtml()
);

// Detect format
const format = transformer.detectFormat(content);

// Extract metadata
const metadata = transformer.extractMetadata(content, 'markdown');

API Reference

ContentTransformer Class

class ContentTransformer {
  constructor(config?: ContentTransformerConfig);
  
  async transform(content: string, options: TransformationOptions): Promise<TransformationResult>;
  detectFormat(content: string): ContentFormat;
  extractMetadata(content: string, format: ContentFormat): Record<string, unknown>;
  getWordCount(content: string): number;
}

Utility Functions

// Quick transformations
contentUtils.markdownToHtml(markdown: string): Promise<string>;
contentUtils.htmlToMarkdown(html: string): Promise<string>;
contentUtils.toText(content: string, sourceFormat?: 'markdown' | 'html'): Promise<string>;
contentUtils.sanitizeHtml(html: string): Promise<string>;
contentUtils.detectFormat(content: string): ContentFormat;
contentUtils.getMetadata(content: string, format?: ContentFormat): Record<string, unknown>;

Presets

transformationPresets.blogMarkdownToHtml(): TransformationOptions;
transformationPresets.emailHtmlSanitize(): TransformationOptions;
transformationPresets.docsMarkdownToHtml(): TransformationOptions;
transformationPresets.commentTextToHtml(): TransformationOptions;
transformationPresets.anyToText(sourceFormat?: 'markdown' | 'html'): TransformationOptions;

Common Configs

commonConfigs.strict(): ContentTransformerConfig;  // Strict sanitization
commonConfigs.blog(): ContentTransformerConfig;    // Blog content processing
commonConfigs.permissive(): ContentTransformerConfig; // Permissive for trusted content

Integration Status

Logger Integration

Status: Not applicable

Justification: This is a pure utility package with no runtime state, side effects, or error conditions that require logging. The ContentTransformer class is stateless and deterministic - it simply transforms content between formats. All errors are thrown as exceptions that calling code can handle, and there are no background operations, network calls, or state changes that would benefit from structured logging.

Pattern: Pure functional utility - no logger integration needed.

NeverHub Integration

Status: Not applicable

Justification: This is a core utility package that performs content format transformations. It does not participate in service discovery, event publishing, or service mesh operations. Content transformation is a stateless utility operation that doesn't require service registration or discovery.

Pattern: Core utility - no service mesh integration needed.

Docs-Suite Integration

Status: Ready

Format: TypeDoc-compatible JSDoc comments are included throughout the source code. All public APIs are documented with examples and type information.

License

Copyright (c) 2025 Bernier LLC. All rights reserved.

This file is licensed to the client under a limited-use license. The client may use and modify this code only within the scope of the project it was delivered for. Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.