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

convatile-sdk

v1.0.0

Published

A template-driven document export engine that converts plain text into Markdown, PDF, DOCX, and HTML

Readme

Convatile-SDK

A template-driven document export engine that converts plain text into Markdown, PDF, DOCX, and HTML formats.

Features

  • Multi-format export: Convert plain text or Markdown to PDF, DOCX, HTML, and Markdown
  • Template support: Customize output with custom templates
  • Metadata injection: Add title, author, date, and other metadata to documents
  • CLI tool: Command-line interface for quick conversions
  • TypeScript: Full TypeScript support with type definitions
  • Zero external calls: All processing happens locally, no network requests

Installation

npm install convatile-sdk

Quick Start

Programmatic API

import { convert } from 'convatile-sdk';

const text = `
# My Document

This is a sample document with **bold** and _italic_ text.

## Features

- Feature 1
- Feature 2
- Feature 3
`;

// Convert to multiple formats at once
const result = await convert(text, {
  format: ['pdf', 'docx', 'html'],
  metadata: {
    title: 'My Document',
    author: 'John Doe',
    date: '2024-01-01'
  }
});

// Access the outputs
console.log(result.pdf);   // Buffer
console.log(result.docx);  // Buffer
console.log(result.html);  // string

CLI Usage

# Convert a file to PDF and DOCX
convatile convert document.md -f pdf,docx -o output/

# Convert text directly
convatile convert "# Hello World" -f html

# Convert with metadata
convatile convert input.txt -f pdf --title "My Report" --author "John Doe"

# Read from stdin
cat document.md | convatile convert --stdin -f pdf -o output/

API Reference

convert(text, options)

Convert text to one or more output formats.

Parameters:

  • text (string): The input text (plain text or Markdown)
  • options (object):
    • format (array): Output formats ('md', 'pdf', 'docx', 'html')
    • templateId (string, optional): Template ID to use
    • metadata (object, optional): Document metadata

Returns: Promise<ConvertResult>

interface ConvertResult {
  md?: string;
  pdf?: Buffer;
  docx?: Buffer;
  html?: string;
}

Convenience Functions

// Convert to specific formats
const markdown = await convertToMarkdown(text, options);
const html = await convertToHtml(text, options);
const pdf = await convertToPdf(text, options);
const docx = await convertToDocx(text, options);

Template Registration

import { registerTemplate } from 'convatile-sdk';

await registerTemplate({
  id: 'my-template',
  name: 'My Custom Template',
  type: 'html',
  path: './templates/custom.html'
});

// Use the template
const result = await convert(text, {
  format: ['html'],
  templateId: 'my-template'
});

Document Metadata

Supported metadata fields:

| Field | Type | Description | |-------|------|-------------| | title | string | Document title | | author | string | Author name | | date | string | Publication date | | description | string | Document description | | keywords | string[] | Keywords for the document |

const result = await convert(text, {
  format: ['pdf', 'html'],
  metadata: {
    title: 'Annual Report 2024',
    author: 'Jane Smith',
    date: '2024-01-15',
    description: 'Company annual report',
    keywords: ['annual', 'report', 'finance']
  }
});

CLI Reference

convatile convert <input>

Convert text or a file to specified formats.

Arguments:

  • <input>: Input file path or text string

Options:

  • -f, --format <formats>: Output formats (comma-separated, default: md)
  • -o, --output <dir>: Output directory (default: .)
  • -n, --name <name>: Output file name (without extension)
  • -t, --template <id>: Template ID to use
  • --title <title>: Document title
  • --author <author>: Document author
  • --stdin: Read input from stdin

convatile templates list

List all registered templates.

convatile templates add <path>

Register a new template.

Options:

  • -i, --id <id>: Template ID
  • -n, --name <name>: Template name
  • -t, --type <type>: Template type (html, pdf, docx)

Custom Templates

HTML Templates

HTML templates use placeholder tokens:

<!DOCTYPE html>
<html>
<head>
  <title>{{TITLE}}</title>
  {{META}}
  <style>{{STYLES}}</style>
</head>
<body>
  {{CONTENT}}
</body>
</html>

Placeholders:

  • {{TITLE}}: Document title
  • {{META}}: Meta tags generated from metadata
  • {{STYLES}}: CSS styles
  • {{CONTENT}}: Rendered HTML content

Error Handling

The SDK exports typed errors for better error handling:

import {
  ConversionError,
  ParseError,
  TemplateError,
  FormatError,
  ValidationError
} from 'convatile-sdk';

try {
  await convert(text, { format: ['pdf'] });
} catch (error) {
  if (error instanceof ConversionError) {
    console.error(`Conversion failed for ${error.format}: ${error.message}`);
  } else if (error instanceof ValidationError) {
    console.error(`Invalid input: ${error.message}`);
  }
}

Requirements

  • Node.js 18 or higher
  • Linux or macOS (Windows support coming soon)

License

MIT