Skip to content

Commit cdf099c

Browse files
committed
Improve readme wording
1 parent bb7ec9a commit cdf099c

1 file changed

Lines changed: 25 additions & 24 deletions

File tree

readme.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
A simple parser for the Netscape Bookmark File Format (NBFF), commonly generated by browsers when exporting bookmarks.
44

5-
It supports parsing bookmarks into various formats — including customizable structures — and converting the parsed data back into an HTML string.
5+
It supports parsing into various formats — including customizable structures — and writing the data back.
66

7-
Additionally, the parser can merge the contents of multiple bookmark files into a single, unified string.
7+
It also supports merging multiple files.
88

99
## Features
1010

@@ -22,7 +22,6 @@ Additionally, the parser can merge the contents of multiple bookmark files into
2222
- [stringify](#stringify)
2323
- [flatStringify](#flatstringify)
2424
- [merge](#merge)
25-
- [Attribute Handling](#attribute-handling)
2625
- [CLI](#cli)
2726
- [exclude](#exclude)
2827
- [merge](#merge-1)
@@ -45,6 +44,8 @@ yarn add nbff-parser
4544

4645
The parser expects HTML file content to be provided as a string.
4746

47+
Returns bookmark attributes with lowercase names and normalized values.
48+
4849
### `parse`
4950

5051
[Type definition](./types/parse/parse.d.ts)
@@ -85,10 +86,10 @@ const bookmarks = parse(html)
8586

8687
You can configure the output by activating options passed as the second argument.
8788

88-
| Option | Type | Description |
89-
| -------------- | ---------- | ------------------------------------------------------------------------------------------- |
90-
| `excludeAttrs` | `string[]` | Excludes specified attributes from output. See [attributes definition](./types/attrs.d.ts). |
91-
| `withId` | `boolean` | Adds hierarchical identifiers `id` and `pid` to each item. |
89+
| Option | Type | Description |
90+
| -------------- | --------------- | -------------------------------------------------------------------------------- |
91+
| `excludeAttrs` | `AllAttrKeys[]` | Excludes specified attributes from output. See [definition](./types/attrs.d.ts). |
92+
| `withId` | `boolean` | Adds hierarchical identifiers `id` and `pid` to each item. |
9293

9394
### `flatParse`
9495

@@ -135,11 +136,11 @@ const bookmarks = flatParse(html)
135136

136137
You can configure the output by activating options passed as the second argument.
137138

138-
| Option | Type | Description |
139-
| -------------- | --------------------------- | ------------------------------------------ |
140-
| `excludeAttrs` | `string[]` | Excludes specified attributes from output. |
141-
| `withId` | `boolean` | Adds incremental numeric `id` to items. |
142-
| `transform` | `(item: FlatBookmark) => T` | Transforms items, omitting falsy returns. |
139+
| Option | Type | Description |
140+
| -------------- | --------------------------- | -------------------------------------------------------------------------------- |
141+
| `excludeAttrs` | `AllAttrKeys[]` | Excludes specified attributes from output. See [definition](./types/attrs.d.ts). |
142+
| `withId` | `boolean` | Adds incremental numeric `id` to items. |
143+
| `transform` | `(item: FlatBookmark) => T` | Transforms items, omitting falsy returns. |
143144

144145
### `customParse`
145146

@@ -155,10 +156,10 @@ The methods described above rely on it internally.
155156
import { customParse } from 'nbff-parser'
156157

157158
const handlers = {
158-
addBookmark,
159-
describeBookmark,
160-
openFolder,
161-
closeFolder
159+
openFolder, // <H1>, <H3>
160+
addBookmark, // <A>
161+
describeBookmark, // <DD>
162+
closeFolder // </DL>
162163
}
163164

164165
const bookmarks = customParse(html, handlers)
@@ -184,7 +185,7 @@ const stringified = stringify(parsed)
184185

185186
Converts the flat list from `flatParse` back into an HTML string.
186187

187-
> It requires using `flatParse` with `{ withId: true }` to ensure unique item IDs, and without `transform` to ensure a known structure.
188+
> It requires using `flatParse` with `{ withId: true }` to ensure unique item IDs.
188189
189190
```js
190191
import { flatParse, flatStringify } from 'nbff-parser'
@@ -198,16 +199,18 @@ const stringified = flatStringify(parsed)
198199

199200
[Type definition](./types/merge/merge.d.ts)
200201

201-
Merges the contents of multiple HTML files into a single HTML string.
202+
Merges parsed files into a single HTML string.
202203

203-
## Attribute Handling
204+
```js
205+
import { merge } from 'nbff-parser'
204206

205-
- Attribute names are returned lowercased.
206-
- Attribute values may be slightly normalized.
207-
- See detailed attribute types [here](./types/attrs.d.ts).
207+
const merged = merge(html1, html2, ...)
208+
```
208209

209210
## CLI
210211

212+
CLI methods work with actual files.
213+
211214
Usage:
212215

213216
```sh
@@ -224,8 +227,6 @@ Removes specified attributes from the HTML file.
224227
| `attrs=attr1,attr2,...` | Comma-separated list of attributes to exclude | Required |
225228
| `output=path/to/output` | Path to save the output file; defaults to input file | Optional |
226229

227-
If `output` is not provided, the changes will overwrite the original file.
228-
229230
Example:
230231

231232
```sh

0 commit comments

Comments
 (0)