

The unified/remark ecosystem is the dominant toolchain for Markdown processing in JavaScript. How does datamark compare?

The remark approach [#the-remark-approach]

Remark gives you an AST (mdast) and lets you write plugins that transform it:

```typescript
import { unified } from "unified";
import remarkParse from "remark-parse";

const tree = unified().use(remarkParse).parse(content);
// Now write a visitor that walks the tree
```

This is powerful and well-supported, but it is fundamentally **imperative**. You write a visitor that mutates or inspects nodes. The structure of your code does not mirror the structure of your document.

The datamark approach [#the-datamark-approach]

datamark gives you a unified AST with a native section tree, plus utility functions for querying and extracting data:

```typescript
function parse(doc) {
  const h1 = doc.root.children.find(n => n.type === "section");
  const title = h1 ? inlineText(h1.heading.children) : "";
  const sections = h1?.children.filter(n => n.type === "section") ?? [];
  return { title, sections };
}
```

This reads like the document itself. The section tree mirrors the heading hierarchy, and utility functions make common patterns trivial.

| Feature        | Remark                 | datamark               |
| -------------- | ---------------------- | ---------------------- |
| Ecosystem size | ✅ Massive              | Small                  |
| AST standard   | mdast                  | datamark AST           |
| Plugin model   | Visitor-based          | Imperative + utilities |
| Bidirectional  | ❌ (separate stringify) | ✅ Built-in             |
| TypeScript     | Partial                | Fully typed            |
| Frontmatter    | Via plugin             | Built-in               |
| Validation     | Via plugin             | Standard Schema        |
| Learning curve | Medium                 | Low                    |

When to use remark [#when-to-use-remark]

If you need to transform Markdown to HTML, apply syntax highlighting, generate a table of contents, or integrate with a massive plugin ecosystem, remark is the right choice.

If you need to **parse Markdown into typed objects** and optionally **serialize them back**, datamark is purpose-built for that job.
