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

@da-tools/da-parser

v1.1.0

Published

Parser for converting DA Admin HTML to DA Live ProseMirror/YDoc format

Readme

DA Parser

Parser for converting DA Admin HTML to ProseMirror/YDoc format and back.

Overview

DA Parser provides bidirectional conversion between:

  • AEM HTML (stored in DA Admin) ↔ ProseMirror documents (used in the DA Live editor)

The parser handles:

  • Block structures (divs with classes → tables for editing)
  • Section breaks (<hr> elements)
  • Images with links (hoisting/unhoisting link attributes)
  • Diff markers (da-diff-added, da-diff-deleted) for regional edits
  • Custom DA metadata
  • List handling with diff markers

Installation

npm install da-parser

Usage

Converting AEM HTML to YDoc

import { aem2doc } from 'da-parser';
import * as Y from 'yjs';

const html = `<body>
  <header></header>
  <main>
    <div>
      <p>Hello world</p>
    </div>
  </main>
  <footer></footer>
</body>`;

const ydoc = new Y.Doc();
aem2doc(html, ydoc);

Converting YDoc back to AEM HTML

import { doc2aem } from 'da-parser';

const html = doc2aem(ydoc);

Using the Schema

import { getSchema, isKnownHTMLTag } from 'da-parser/schema';

const schema = getSchema();

// Check if a tag is recognized
isKnownHTMLTag('div'); // true
isKnownHTMLTag('custom-element'); // false

Exports

| Export | Description | |--------|-------------| | aem2doc(html, ydoc) | Convert AEM HTML string to YDoc | | doc2aem(ydoc) | Convert YDoc back to AEM HTML | | tableToBlock(child, fragment) | Convert a table node to block structure | | EMPTY_DOC | Empty document HTML template | | getSchema() | Get the ProseMirror schema | | isKnownHTMLTag(tag) | Check if tag is a known HTML element | | prosemirrorToYXmlFragment | Re-exported from y-prosemirror | | yDocToProsemirror | Re-exported from y-prosemirror |

Development

# Install dependencies
npm install

# Run all tests (both environments)
npm test

# Run browser tests only (DOMParser path)
npm run test:browser

# Run Node.js tests only (hast-util-from-html path)
npm run test:node

# Run linter
npm run lint

Testing Strategy

The parser has two HTML parsing code paths:

  • Browser: Uses native DOMParser (zero bundle size)
  • Node.js/Workers: Uses hast-util-from-html

The same test files run in both environments to ensure parity:

  • npm run test:browser - Tests run in Chrome via @web/test-runner (wtr)
  • npm run test:node - Tests run in Node.js via mocha

The test/test-utils.js module provides environment-agnostic utilities (expect, readTestFile) that work in both wtr and mocha.

Test Fixtures

  • htmldown/ - HTML files for parser testing
  • htmltest/ - Additional HTML test cases
  • test/mocks/ - Mock HTML files for specific test scenarios

License

Apache-2.0