nizel 0.1.0 → 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.
- package/README.md +102 -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 +17 -3
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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-abbr` — abbreviation definitions with `<abbr>` output
|
|
79
|
+
- `nizel-plugin-alert` — GitHub-style and custom alert blocks
|
|
80
|
+
- `nizel-plugin-autolink` — configurable bare URL and email links
|
|
81
|
+
- `nizel-plugin-citations` — citation references and bibliography output
|
|
82
|
+
- `nizel-plugin-code-copy` — CSP-friendly copy controls for code blocks
|
|
83
|
+
- `nizel-plugin-deflist` — definition-list syntax
|
|
84
|
+
- `nizel-plugin-details` — disclosure/details blocks
|
|
85
|
+
- `nizel-plugin-diagrams` — Mermaid code block containers
|
|
86
|
+
- `nizel-plugin-emoji` — `:name:` emoji shortcuts
|
|
87
|
+
- `nizel-plugin-footnotes` — footnote references and definitions
|
|
88
|
+
- `nizel-plugin-frontmatter-ui` — frontmatter metadata rendering helpers
|
|
89
|
+
- `nizel-plugin-gfm` — GFM-oriented plugin preset
|
|
90
|
+
- `nizel-plugin-heading-anchors` — visible anchor links on headings
|
|
91
|
+
- `nizel-plugin-math` — inline and display math wrappers
|
|
92
|
+
- `nizel-plugin-media` — figure, caption, lazy, and responsive image helpers
|
|
93
|
+
- `nizel-plugin-sanitize` — additional rendered HTML sanitizing
|
|
94
|
+
- `nizel-plugin-shiki` — code syntax highlighting via Shiki
|
|
95
|
+
- `nizel-plugin-toc` — rendered `[[toc]]` table of contents
|
|
96
|
+
- `nizel-plugin-typography` — mark, subscript, and superscript extensions
|
|
97
|
+
|
|
98
|
+
For native apps or WebViews that need a single browser bundle with a settings-friendly plugin registry, use `nizel-kit`.
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT
|