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

@uniweb/content-writer

v0.2.4

Published

ProseMirror document structure to Markdown converter

Downloads

670

Readme

Content Writer

A JavaScript library for converting ProseMirror/TipTap document JSON back to Markdown. The inverse of @uniweb/content-reader.

Features

  • Full round-trip fidelity with @uniweb/content-reader
  • Headings, paragraphs, blockquotes, horizontal rules
  • Bold, italic, inline code, and nested formatting
  • Links with title, attributes, and download support
  • Buttons with variant, size, and icon attributes
  • Bracketed spans with class, ID, and custom attributes
  • Images with role, caption, dimensions, fit/position
  • Video and PDF media with playback/preview attributes
  • Icons (library+name dash format and icon: prefix)
  • Component references (@ComponentName inset syntax)
  • Fenced code blocks with language and tagged data blocks
  • Bullet and ordered lists with nesting
  • GFM tables with column alignment
  • YAML frontmatter serialization
  • Plain text extraction (no formatting, just content)

Installation

npm install @uniweb/content-writer

Usage

Convert ProseMirror to Markdown

import { proseMirrorToMarkdown } from '@uniweb/content-writer'

const doc = {
  type: 'doc',
  content: [
    {
      type: 'heading',
      attrs: { level: 1 },
      content: [{ type: 'text', text: 'Hello World' }]
    },
    {
      type: 'paragraph',
      content: [
        { type: 'text', text: 'This is ' },
        { type: 'text', text: 'bold', marks: [{ type: 'bold' }] },
        { type: 'text', text: ' text.' }
      ]
    }
  ]
}

const markdown = proseMirrorToMarkdown(doc)
// # Hello World
//
// This is **bold** text.

Serialize a Complete Section File

import { serializeSection } from '@uniweb/content-writer'

const params = { type: 'Hero', alignment: 'center' }
const doc = {
  type: 'doc',
  content: [
    { type: 'heading', attrs: { level: 1 }, content: [{ type: 'text', text: 'Welcome' }] }
  ]
}

const file = serializeSection(params, doc)
// ---
// type: Hero
// alignment: center
// ---
//
// # Welcome

Serialize Frontmatter Only

import { serializeFrontmatter } from '@uniweb/content-writer'

const yaml = serializeFrontmatter({ type: 'Hero', hidden: true })
// ---
// type: Hero
// hidden: true
// ---

Extract Plain Text

Strip all formatting and return just the text content. Useful for word counting, search indexing, and generating summaries.

import { docToPlainText } from '@uniweb/content-writer'

const doc = {
  type: 'doc',
  content: [
    { type: 'heading', attrs: { level: 1 }, content: [{ type: 'text', text: 'Title' }] },
    {
      type: 'paragraph',
      content: [
        { type: 'text', text: 'Click ' },
        { type: 'text', text: 'here', marks: [{ type: 'link', attrs: { href: '/page' } }] },
        { type: 'text', text: ' for details.' }
      ]
    }
  ]
}

const text = docToPlainText(doc)
// Title
//
// Click here for details.

docToPlainText preserves text from headings, paragraphs, lists, code blocks, blockquotes, and tables. It strips all marks (bold, italic, links) and skips images, dividers, component references, and data blocks.

Using with TipTap

import { Editor } from '@tiptap/core'
import { proseMirrorToMarkdown } from '@uniweb/content-writer'

// Get markdown from editor state
const markdown = proseMirrorToMarkdown(editor.getJSON())

Extended Syntax

The serializer handles the same extended syntax as @uniweb/content-reader:

Curly Brace Attributes

![Hero](./hero.jpg){role=hero width=1200 fit=cover}
[Styled text]{.highlight .large}
[Download](./file.pdf){download="report.pdf"}

Buttons

[Get Started](button:https://example.com){variant=primary size=lg}
[Learn More](button:/docs){variant=secondary icon=arrow-right}

Icons

![](lu-house)
![Logo](icon:./logo.svg)

Component References

![description](@ComponentName){param=value}

Tables with Alignment

| Left | Center | Right |
| :--- | :----: | ----: |
| Text |  Text  |  Text |

API

| Export | Signature | Description | |--------|-----------|-------------| | proseMirrorToMarkdown | (doc) => string | Convert ProseMirror document JSON to markdown | | serializeSection | (params, doc) => string | Serialize frontmatter + body as a complete file | | serializeFrontmatter | (params) => string | Serialize an object to a YAML frontmatter block | | docToPlainText | (doc) => string | Extract plain text content (no formatting) |

Development

git clone https://github.com/uniweb/content-writer.git
cd content-writer
npm install
npm test

License

GPL-3.0-or-later