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

@tryghost/algolia-html-extractor

v0.1.1

Published

Extract ordered searchable fragments from Ghost-rendered HTML

Readme

Ghost Algolia HTML extractor

@tryghost/algolia-html-extractor turns rendered Ghost HTML into an ordered list of fragments. It is an ESM-only package. Both extraction functions are synchronous and exported from the package root.

import {
    extract,
    type ExtractionFragment
} from '@tryghost/algolia-html-extractor';

const fragments: readonly ExtractionFragment[] = extract(ghostContent.html);

What it extracts

extract tracks the current h1 through h6 path while it walks the document. It emits fragments for p, pre, td, and li elements in document order. Empty elements are skipped, but whitespace is kept.

Each fragment contains the element's serialized HTML and text, its heading path and anchor, its position, its heading rank, and the source tag. The returned values are read-only.

The package handles HTML parsing itself and has no configuration options. Turning fragments into Algolia records, merging pre content, and sending records to Algolia are separate jobs handled by the downstream packages.

Rich extraction

Use extractRich to include table headers, captions, citations, plain blockquotes, meaningful image alternatives, and supported authored Ghost card content:

import {extractRich} from '@tryghost/algolia-html-extractor';

const fragments = extractRich(ghostContent.html);

Rich fragments use a read-only source object in place of sourceTag. Its kind is element or attribute; image alternatives identify the alt attribute. Every fragment's html is ready for grouping, including escaped image alternative text. Element HTML retains the input's trust boundary; the extractor is not an HTML sanitizer. Newly selected rich elements omit excluded descendants from their HTML and text.

Rich extraction excludes card controls and hidden content from the additional roles. It keeps legacy fragments and suppresses repeated rich meaning only within the same semantic container, such as an image and its caption. See the selection rules for details.

Calling extract keeps its existing output. To build Algolia records with rich extraction, use the fragmenter's extraction: 'rich' option.

Maintainer smoke check

Maintainers can run the Live Ghost content smoke workflow by hand to check published posts and pages from main.ghost.is. It runs only from this repository's main branch and writes a privacy-safe structural summary to the job. It does not save live content, write a baseline, run on pull requests, or publish the package.

The workflow installs the workspace and then runs:

pnpm --filter @tryghost/algolia-html-extractor smoke:live

This command expects the workflow's URL, API version, Content API key, and job-summary environment. It is not a general-purpose extractor command.