@markdown-for-agents/hono 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +77 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @markdown-for-agents/hono
2
+
3
+ Hono middleware for [markdown-for-agents](https://www.npmjs.com/package/markdown-for-agents) — a runtime-agnostic HTML to Markdown converter built for AI agents.
4
+
5
+ Add one line to your Hono app and AI agents get clean, token-efficient Markdown instead of HTML. Normal browser requests pass through untouched.
6
+
7
+ ## How it works
8
+
9
+ The middleware uses content negotiation. When a client sends `Accept: text/markdown`, HTML responses are automatically converted to Markdown. The response includes:
10
+
11
+ - `Content-Type: text/markdown; charset=utf-8`
12
+ - `x-markdown-tokens` header with the token count
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @markdown-for-agents/hono markdown-for-agents
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```ts
23
+ import { Hono } from 'hono';
24
+ import { markdown } from '@markdown-for-agents/hono';
25
+
26
+ const app = new Hono();
27
+ app.use(markdown({ extract: true }));
28
+
29
+ app.get('/', c => {
30
+ return c.html('<h1>Hello</h1>');
31
+ });
32
+
33
+ export default app;
34
+ ```
35
+
36
+ ```bash
37
+ # Normal HTML response
38
+ curl http://localhost:3000
39
+
40
+ # Markdown response for AI agents
41
+ curl -H "Accept: text/markdown" http://localhost:3000
42
+ ```
43
+
44
+ ## Options
45
+
46
+ Accepts all [`markdown-for-agents` options](https://www.npmjs.com/package/markdown-for-agents#options):
47
+
48
+ ```ts
49
+ app.use(
50
+ markdown({
51
+ // Strip nav, ads, sidebars, cookie banners
52
+ extract: true,
53
+
54
+ // Resolve relative URLs
55
+ baseUrl: 'https://example.com',
56
+
57
+ // Remove duplicate content blocks
58
+ deduplicate: true,
59
+
60
+ // Custom token counter (e.g. tiktoken)
61
+ tokenCounter: text => ({ tokens: enc.encode(text).length, characters: text.length, words: text.split(/\s+/).filter(Boolean).length })
62
+ })
63
+ );
64
+ ```
65
+
66
+ ## Other frameworks
67
+
68
+ | Package | Framework |
69
+ | -------------------------------------------------------------------------------------------- | -------------------------------------------- |
70
+ | [`@markdown-for-agents/express`](https://www.npmjs.com/package/@markdown-for-agents/express) | Express |
71
+ | [`@markdown-for-agents/fastify`](https://www.npmjs.com/package/@markdown-for-agents/fastify) | Fastify |
72
+ | [`@markdown-for-agents/nextjs`](https://www.npmjs.com/package/@markdown-for-agents/nextjs) | Next.js |
73
+ | [`@markdown-for-agents/web`](https://www.npmjs.com/package/@markdown-for-agents/web) | Web Standard (Cloudflare Workers, Deno, Bun) |
74
+
75
+ ## License
76
+
77
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdown-for-agents/hono",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Hono middleware for markdown-for-agents",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -20,7 +20,7 @@
20
20
  "main": "./dist/index.mjs",
21
21
  "types": "./dist/index.d.mts",
22
22
  "dependencies": {
23
- "markdown-for-agents": "0.1.1"
23
+ "markdown-for-agents": "0.1.2"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "hono": ">=4.0.0"