nizel 0.1.0 → 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 +84 -0
- package/dist/browser/nizel.iife.js +4748 -0
- package/dist/browser/nizel.js +4723 -0
- package/dist/browser.d.ts +41 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +157 -0
- package/dist/browser.js.map +1 -0
- package/dist/collect.js +37 -29
- package/dist/collect.js.map +1 -1
- package/dist/html-to-markdown.d.ts +9 -0
- package/dist/html-to-markdown.d.ts.map +1 -0
- package/dist/html-to-markdown.js +434 -0
- package/dist/html-to-markdown.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/parse/inline.d.ts.map +1 -1
- package/dist/parse/inline.js +23 -2
- package/dist/parse/inline.js.map +1 -1
- package/dist/parse/lines.d.ts +4 -0
- package/dist/parse/lines.d.ts.map +1 -1
- package/dist/parse/lines.js +29 -22
- package/dist/parse/lines.js.map +1 -1
- package/dist/parse/list.js +1 -1
- package/dist/parse/list.js.map +1 -1
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +58 -20
- package/dist/parse.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +199 -50
- package/dist/render.js.map +1 -1
- package/dist/use-nizel.d.ts.map +1 -1
- package/dist/use-nizel.js +128 -65
- package/dist/use-nizel.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -5
- package/dist/utils.js.map +1 -1
- package/package.json +15 -2
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# nizel
|
|
2
|
+
|
|
3
|
+
Markdown content processor for modern applications.
|
|
4
|
+
|
|
5
|
+
Custom CommonMark 0.31 parser with frontmatter, templates, filters, elements, plugins, custom blocks, and transforms. No third-party markdown libraries.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install nizel
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { useNizel } from 'nizel';
|
|
17
|
+
|
|
18
|
+
const processor = useNizel({
|
|
19
|
+
// optional configuration
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const result = processor.process('# Hello {{ name }}', {
|
|
23
|
+
data: { name: 'World' }
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Result
|
|
28
|
+
|
|
29
|
+
`process()` returns:
|
|
30
|
+
|
|
31
|
+
- `files` — output files (HTML by default)
|
|
32
|
+
- `pages` — page metadata from frontmatter
|
|
33
|
+
- `project` — project-level data
|
|
34
|
+
- `languages` — language info
|
|
35
|
+
|
|
36
|
+
## Convenience Methods
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
processor.parse(markdown); // AST only, no rendering
|
|
40
|
+
processor.render(markdown); // HTML string
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **CommonMark 0.31** — full spec compliance (652/652 tests)
|
|
46
|
+
- **Frontmatter** — YAML with arrays, templates, and variable resolution
|
|
47
|
+
- **Filters** — 14 built-in: camel, capital, const, dot, header, kebab, lower, pascal, path, sentence, slug, snake, upper, format
|
|
48
|
+
- **Elements** — customize HTML tags and attributes for any node type
|
|
49
|
+
- **Templates** — `{{ variable }}` syntax with filter chains
|
|
50
|
+
- **Plugins** — `defineNizelPlugin()` with `beforeParse`, `afterParse`, `afterRender` hooks
|
|
51
|
+
- **Custom blocks** — `defineBlock()` for domain-specific content
|
|
52
|
+
- **Transforms** — post-processing pipeline
|
|
53
|
+
- **Presets** — `blog`, `email` built-in, or create your own
|
|
54
|
+
- **Safety** — `onclick`/`onerror` handlers stripped, `javascript:` URLs stripped
|
|
55
|
+
- **TOC** — table of contents with level/slug aliases
|
|
56
|
+
|
|
57
|
+
## Options
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
useNizel({
|
|
61
|
+
data: {}, // template variables
|
|
62
|
+
variables: {}, // alias for data
|
|
63
|
+
preset: 'blog', // or 'email', or custom object
|
|
64
|
+
slugStyle: 'kebab', // slug generation style
|
|
65
|
+
elements: {
|
|
66
|
+
a: { tag: 'a', attrs: { target: '_blank' } }
|
|
67
|
+
},
|
|
68
|
+
plugins: [myPlugin()],
|
|
69
|
+
filters: { custom: (v) => v.toUpperCase() },
|
|
70
|
+
blocks: { note: myNoteBlock },
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Plugins
|
|
75
|
+
|
|
76
|
+
Official plugins available:
|
|
77
|
+
|
|
78
|
+
- `nizel-plugin-autolink` — configure autolink behavior
|
|
79
|
+
- `nizel-plugin-code-copy` — CSP-friendly copy buttons on code blocks
|
|
80
|
+
- `nizel-plugin-shiki` — code syntax highlighting via Shiki
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|