formatferry 0.1.1
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.
- package/README.md +230 -0
- package/dist/index.js +22623 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# FormatFerry CLI
|
|
2
|
+
|
|
3
|
+
Convert HTML, DOCX, PDF, XLSX, and CSV to clean Markdown from the command line.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g formatferry
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Requires Node.js 18+.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Pipe HTML from stdin
|
|
15
|
+
echo '<h1>Hello</h1><p>World</p>' | formatferry
|
|
16
|
+
|
|
17
|
+
# Convert a file
|
|
18
|
+
formatferry -i document.html -o output.md
|
|
19
|
+
|
|
20
|
+
# Convert a Word document
|
|
21
|
+
formatferry -i report.docx -o report.md
|
|
22
|
+
|
|
23
|
+
# Convert a PDF
|
|
24
|
+
formatferry -i paper.pdf -o paper.md
|
|
25
|
+
|
|
26
|
+
# Convert a spreadsheet
|
|
27
|
+
formatferry -i data.xlsx -o data.md
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
### Convert (default)
|
|
33
|
+
|
|
34
|
+
The default command converts input to Markdown.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
formatferry [options]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| Option | Description |
|
|
41
|
+
|--------|-------------|
|
|
42
|
+
| `-i, --input <path>` | Input file path (.html, .htm, .docx, .pdf, .xlsx, .csv) |
|
|
43
|
+
| `-o, --output <path>` | Output file path (defaults to stdout) |
|
|
44
|
+
| `-f, --format <format>` | Markdown format (default: `github`) |
|
|
45
|
+
| `--url <url>` | Fetch and convert a web article (requires API key) |
|
|
46
|
+
| `--batch <glob>` | Batch convert files matching a glob pattern (Premium) |
|
|
47
|
+
| `--output-dir <dir>` | Output directory for batch mode |
|
|
48
|
+
|
|
49
|
+
#### Input Modes
|
|
50
|
+
|
|
51
|
+
1. **stdin** — pipe HTML content directly:
|
|
52
|
+
```bash
|
|
53
|
+
cat page.html | formatferry
|
|
54
|
+
pbpaste | formatferry # macOS clipboard
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
2. **File** — use `--input` for local files:
|
|
58
|
+
```bash
|
|
59
|
+
formatferry -i report.docx
|
|
60
|
+
formatferry -i data.xlsx -f commonmark
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
3. **URL** — fetch and extract a web article (requires API key):
|
|
64
|
+
```bash
|
|
65
|
+
formatferry --url https://example.com/article
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Supported Formats
|
|
69
|
+
|
|
70
|
+
| Format | Flag Value | Description |
|
|
71
|
+
|--------|-----------|-------------|
|
|
72
|
+
| GitHub Flavored Markdown | `github` | Default. Tables, task lists, strikethrough |
|
|
73
|
+
| CommonMark | `commonmark` | Strict CommonMark spec |
|
|
74
|
+
| Slack | `slack` | Slack mrkdwn syntax |
|
|
75
|
+
| Discord | `discord` | Discord Markdown |
|
|
76
|
+
| Reddit | `reddit` | Reddit Markdown |
|
|
77
|
+
| Confluence | `confluence` | Confluence wiki markup |
|
|
78
|
+
| R Markdown | `rmarkdown` | R Markdown with YAML front matter |
|
|
79
|
+
| Custom | `custom` | Base Markdown with no format-specific rules |
|
|
80
|
+
|
|
81
|
+
#### Supported File Types
|
|
82
|
+
|
|
83
|
+
| Extension | Type | Notes |
|
|
84
|
+
|-----------|------|-------|
|
|
85
|
+
| `.html`, `.htm` | HTML | Rich text, web pages, Google Docs exports |
|
|
86
|
+
| `.docx` | Word | Microsoft Word documents (via Mammoth.js) |
|
|
87
|
+
| `.pdf` | PDF | Text extraction (via PDF.js) |
|
|
88
|
+
| `.xlsx` | Excel | Spreadsheets with multi-sheet support (via SheetJS) |
|
|
89
|
+
| `.csv` | CSV | Comma-separated data files |
|
|
90
|
+
|
|
91
|
+
### Auth
|
|
92
|
+
|
|
93
|
+
Manage license keys and API keys.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
formatferry auth [options]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
| Option | Description |
|
|
100
|
+
|--------|-------------|
|
|
101
|
+
| `--license-key <key>` | Activate a license key |
|
|
102
|
+
| `--api-key <key>` | Activate an API key |
|
|
103
|
+
| `--status` | Show current license/plan status |
|
|
104
|
+
| `--logout` | Remove stored credentials |
|
|
105
|
+
|
|
106
|
+
#### License Key
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Activate a license key
|
|
110
|
+
formatferry auth --license-key FF-PREM-XXXX-XXXX
|
|
111
|
+
|
|
112
|
+
# Check status
|
|
113
|
+
formatferry auth --status
|
|
114
|
+
|
|
115
|
+
# Remove credentials
|
|
116
|
+
formatferry auth --logout
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### API Key
|
|
120
|
+
|
|
121
|
+
API keys enable URL extraction and are available through subscription plans.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Activate an API key
|
|
125
|
+
formatferry auth --api-key ff_your_api_key_here
|
|
126
|
+
|
|
127
|
+
# Check plan and quota
|
|
128
|
+
formatferry auth --status
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Plans
|
|
132
|
+
|
|
133
|
+
| Plan | Features | Batch | URL Extraction |
|
|
134
|
+
|------|----------|-------|----------------|
|
|
135
|
+
| Free | Basic conversion | No | No |
|
|
136
|
+
| Pro | Atlassian parsing, token optimization, batch | Yes | Yes |
|
|
137
|
+
| Credits | Pay-per-use URL extraction | No | Yes |
|
|
138
|
+
| Agent Starter | All Pro features + rate limit | Yes | Yes |
|
|
139
|
+
| Agent Pro | All Pro features + higher rate limit | Yes | Yes |
|
|
140
|
+
| Agent Scale | All Pro features + highest rate limit | Yes | Yes |
|
|
141
|
+
|
|
142
|
+
### Batch Convert (Premium)
|
|
143
|
+
|
|
144
|
+
Convert multiple files at once using glob patterns.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Convert all HTML files in a directory
|
|
148
|
+
formatferry --batch "docs/*.html"
|
|
149
|
+
|
|
150
|
+
# Convert to a specific output directory
|
|
151
|
+
formatferry --batch "**/*.html" --output-dir converted/
|
|
152
|
+
|
|
153
|
+
# Convert with a specific format
|
|
154
|
+
formatferry --batch "*.docx" -f commonmark --output-dir output/
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Batch mode requires a Premium license or a Pro/Agent API key. Output files are written with `.md` extension alongside the source files, or to `--output-dir` if specified.
|
|
158
|
+
|
|
159
|
+
The batch summary reports success/failure counts:
|
|
160
|
+
```
|
|
161
|
+
Batch complete: 5 succeeded, 1 failed, 6 total
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Files that fail conversion (e.g., unsupported types in a broad glob) are logged to stderr and skipped — remaining files continue processing.
|
|
165
|
+
|
|
166
|
+
## Configuration
|
|
167
|
+
|
|
168
|
+
Credentials are stored in a platform-specific config file:
|
|
169
|
+
|
|
170
|
+
| Platform | Path |
|
|
171
|
+
|----------|------|
|
|
172
|
+
| macOS/Linux | `~/.config/formatferry/config.json` |
|
|
173
|
+
| Windows | `%APPDATA%\formatferry\config.json` |
|
|
174
|
+
|
|
175
|
+
The config file is created with `0600` permissions (owner read/write only) on POSIX systems.
|
|
176
|
+
|
|
177
|
+
### Entitlement Caching
|
|
178
|
+
|
|
179
|
+
License keys are validated against the FormatFerry license server on each CLI invocation with a 2-second timeout. If the server is unreachable:
|
|
180
|
+
|
|
181
|
+
- **Cache < 7 days old**: Cached entitlements are used
|
|
182
|
+
- **Cache > 7 days old**: Falls back to free tier with a warning
|
|
183
|
+
|
|
184
|
+
Revoked keys are automatically removed from the config.
|
|
185
|
+
|
|
186
|
+
## Exit Codes
|
|
187
|
+
|
|
188
|
+
| Code | Meaning |
|
|
189
|
+
|------|---------|
|
|
190
|
+
| 0 | Success |
|
|
191
|
+
| 1 | Error (invalid input, missing file, auth failure, unsupported format) |
|
|
192
|
+
|
|
193
|
+
All errors are written to stderr. Conversion output goes to stdout (unless `--output` is specified).
|
|
194
|
+
|
|
195
|
+
## Examples
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Convert clipboard HTML to Markdown (macOS)
|
|
199
|
+
pbpaste | formatferry | pbcopy
|
|
200
|
+
|
|
201
|
+
# Convert a Google Docs export
|
|
202
|
+
formatferry -i "My Document.html" -o document.md
|
|
203
|
+
|
|
204
|
+
# Convert all Word docs in a project
|
|
205
|
+
formatferry --batch "reports/**/*.docx" --output-dir markdown/
|
|
206
|
+
|
|
207
|
+
# Extract and convert a web article
|
|
208
|
+
formatferry --url https://blog.example.com/post -o article.md
|
|
209
|
+
|
|
210
|
+
# Use CommonMark format for strict compatibility
|
|
211
|
+
formatferry -i page.html -f commonmark
|
|
212
|
+
|
|
213
|
+
# Pipe through other tools
|
|
214
|
+
curl -s https://example.com | formatferry -f reddit
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Install dependencies (from repo root)
|
|
221
|
+
npm install
|
|
222
|
+
|
|
223
|
+
# Run tests
|
|
224
|
+
npm test --workspace=packages/cli
|
|
225
|
+
|
|
226
|
+
# Build
|
|
227
|
+
npm run build --workspace=packages/cli
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
See [PUBLISHING.md](./PUBLISHING.md) for npm publish instructions.
|