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

nav-invoicedata-to-html

v2.0.0

Published

Hungarian NAV Online Invoice (OSA) XML data to HTML viewer and generator.

Readme

NAV InvoiceData to HTML

A library to parse NAV Online Invoice XML data and generate a premium, localized HTML representation.

Installation

npm install nav-invoicedata-to-html

Requirements

  • Node.js >= 18.0.0
  • ESM support (The library is built as an ES Module)

Dependencies

  • nav-osa-types — shared NAV OSA types, XML parsing, and XSD validation

Usage

Since the library uses libxml2-wasm (via nav-osa-types) with top-level await, it must be imported dynamically in CommonJS environments.

Basic Usage (ESM)

import { generateInvoiceHtml } from 'nav-invoicedata-to-html';

const xmlData = '...'; // Your NAV XML string
const html = await generateInvoiceHtml(xmlData);

Usage in CommonJS (e.g. ts-node-dev)

To avoid require() errors with top-level await modules, use the dynamic import trick:

// Use Function trick to prevent tsc from transpiling to require()
const navHtml = await new Function('return import("nav-invoicedata-to-html")')();
const { generateInvoiceHtml } = navHtml;

const html = await generateInvoiceHtml(xmlData);

Options

generateInvoiceHtml accepts an optional second parameter with the following properties:

| Property | Type | Default | Description | |----------|------|---------|-------------| | locale | string | 'hu' | Language (hu, en, ...) | | xsdPath | string | built-in data.xsd | Custom XSD schema path | | cssConfig | CssConfig | external link | CSS configuration (see below) | | validate | boolean | true | XSD validation (disable with false) |

const html = await generateInvoiceHtml(xmlData, {
  locale: 'en',
  xsdPath: '/path/to/custom.xsd'
});

// Skip validation if XML is already trusted
const html = await generateInvoiceHtml(xmlData, { validate: false });

CSS Configuration

By default, the generated HTML references invoice-styles.css via a <link> tag. You can customize this via cssConfig:

External CSS file

const html = await generateInvoiceHtml(xmlData, {
  cssConfig: { path: 'my-custom.css' }
});

Inline CSS

import fs from 'fs/promises';

const cssContent = await fs.readFile('my-custom.css', 'utf-8');
const html = await generateInvoiceHtml(xmlData, {
  cssConfig: { inline: cssContent }
});

CssConfig properties:

  • path — URL or file path for an external stylesheet (<link> tag)
  • inline — Raw CSS content to embed directly (<style> tag)

If neither is provided, it defaults to <link rel="stylesheet" href="invoice-styles.css">.

Features

  • Validation: Validates XML against NAV XSD schemas via nav-osa-types.
  • Parsing: Converts complex NAV XML structures into typed JavaScript objects.
  • HTML Generation: Produces a clean, styled HTML version of the invoice.
  • Security: Built-in HTML escaping via @kitajs/html to prevent XSS (Cross-Site Scripting) vulnerabilities when rendering untrusted XML data.
  • Localization: Supports multiple locales (default: hu, en).
  • JSX Rendering: Uses @kitajs/html for component-based template rendering with JSX.

License

Apache-2.0