markedin-parser 0.1.1 โ 0.1.3
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 +61 -71
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# markedin-parser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Markedin (`.mi`) is a file format for both machines and humans. YAML frontmatter + templated Markdown.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`markedin-parser` parses and renders `.mi` (markedin) files. No framework required. Perfect for file-based agentic systems.
|
|
6
6
|
|
|
7
7
|
Full documentation at [markedin.dev](https://markedin.dev)
|
|
8
8
|
|
|
@@ -12,9 +12,61 @@ Full documentation at [markedin.dev](https://markedin.dev)
|
|
|
12
12
|
npm install markedin-parser
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Markedin .mi Format
|
|
16
|
+
|
|
17
|
+
A `.mi` file has YAML frontmatter between `---` delimiters and a Markdown body that renders from it.
|
|
18
|
+
|
|
19
|
+
`task.mi`:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
---
|
|
23
|
+
task: Implement rate limiting
|
|
24
|
+
status: in_progress
|
|
25
|
+
owner:
|
|
26
|
+
name: Dana
|
|
27
|
+
team: Platform
|
|
28
|
+
priority: high
|
|
29
|
+
notes:
|
|
30
|
+
- Token bucket algorithm chosen over leaky bucket
|
|
31
|
+
- Limit is 100 req/min per API key
|
|
32
|
+
- Redis required for distributed enforcement
|
|
33
|
+
blocked: false
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
# {{task}}
|
|
37
|
+
|
|
38
|
+
**Status:** {{status}} ยท **Owner:** {{owner.name}} ({{owner.team}}) ยท **Priority:** {{priority}}
|
|
39
|
+
|
|
40
|
+
First note: {{notes[0]}}
|
|
41
|
+
|
|
42
|
+
## Notes
|
|
43
|
+
|
|
44
|
+
{{#each notes}}
|
|
45
|
+
- {{this}}
|
|
46
|
+
{{/each}}
|
|
47
|
+
|
|
48
|
+
{{#if blocked}}
|
|
49
|
+
โ ๏ธ This task is currently blocked.
|
|
50
|
+
{{else}}
|
|
51
|
+
โ
No blockers.
|
|
52
|
+
{{/if}}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Template Expressions
|
|
56
|
+
|
|
57
|
+
| Expression | Description |
|
|
58
|
+
| ---------------------------------- | -------------------------------------------- |
|
|
59
|
+
| `{{key}}` | Scalar value (arrays render comma-separated) |
|
|
60
|
+
| `{{key.nested}}` | Dot-path into objects |
|
|
61
|
+
| `{{array[0]}}` | Array index access |
|
|
62
|
+
| `{{#each items}}...{{/each}}` | Iterate an array |
|
|
63
|
+
| `{{#if key}}...{{else}}...{{/if}}` | Conditional block |
|
|
64
|
+
| `{{> key}}` | Inline a frontmatter string as raw text |
|
|
65
|
+
|
|
66
|
+
## Parsing and Rendering a Markedin File
|
|
16
67
|
|
|
17
68
|
```javascript
|
|
69
|
+
const fs = require("fs");
|
|
18
70
|
const {
|
|
19
71
|
parse,
|
|
20
72
|
render,
|
|
@@ -22,27 +74,11 @@ const {
|
|
|
22
74
|
renderHtml,
|
|
23
75
|
} = require("markedin-parser");
|
|
24
76
|
|
|
25
|
-
const source =
|
|
26
|
-
title: My Project
|
|
27
|
-
status: active
|
|
28
|
-
items:
|
|
29
|
-
- name: Alpha
|
|
30
|
-
status: stable
|
|
31
|
-
- name: Beta
|
|
32
|
-
status: experimental
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
# {{title}}
|
|
36
|
-
|
|
37
|
-
**Status:** {{status}}
|
|
38
|
-
|
|
39
|
-
{{#each items}}
|
|
40
|
-
- **{{name}}** โ {{status}}
|
|
41
|
-
{{/each}}`;
|
|
77
|
+
const source = fs.readFileSync("task.mi", "utf8");
|
|
42
78
|
|
|
43
79
|
// Extract frontmatter and body
|
|
44
80
|
const { data, body } = parse(source);
|
|
45
|
-
// data โ {
|
|
81
|
+
// data โ { task: 'Implement rate limiting', status: 'in_progress', owner: { name: 'Dana', ... }, ... }
|
|
46
82
|
|
|
47
83
|
// Render to markdown (template expressions resolved)
|
|
48
84
|
render(source);
|
|
@@ -58,7 +94,7 @@ render(source, { embed: true }); // appends as HTML comment
|
|
|
58
94
|
renderHtml(source, { embed: true }); // adds <script> tag in <head>
|
|
59
95
|
```
|
|
60
96
|
|
|
61
|
-
## API
|
|
97
|
+
## Markedin Parser API
|
|
62
98
|
|
|
63
99
|
### `parse(source)` โ `{ data, body }`
|
|
64
100
|
|
|
@@ -85,56 +121,10 @@ Options: `{ embed: true }` includes frontmatter as a `<script type="application/
|
|
|
85
121
|
Resolve a dotted/bracketed path against a data object.
|
|
86
122
|
|
|
87
123
|
```javascript
|
|
88
|
-
resolvePath(data, "
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
## Template expressions
|
|
92
|
-
|
|
93
|
-
| Expression | Description |
|
|
94
|
-
| ---------------------------------- | -------------------------------------------- |
|
|
95
|
-
| `{{key}}` | Scalar value (arrays render comma-separated) |
|
|
96
|
-
| `{{key.nested}}` | Dot-path into objects |
|
|
97
|
-
| `{{array[0]}}` | Array index access |
|
|
98
|
-
| `{{#each items}}...{{/each}}` | Iterate an array |
|
|
99
|
-
| `{{#if key}}...{{else}}...{{/if}}` | Conditional block |
|
|
100
|
-
| `{{> key}}` | Inline a frontmatter string as raw text |
|
|
101
|
-
|
|
102
|
-
## Example
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
---
|
|
106
|
-
task: Implement rate limiting
|
|
107
|
-
status: in_progress
|
|
108
|
-
owner:
|
|
109
|
-
name: Dana
|
|
110
|
-
team: Platform
|
|
111
|
-
priority: high
|
|
112
|
-
notes:
|
|
113
|
-
- Token bucket algorithm chosen over leaky bucket
|
|
114
|
-
- Limit is 100 req/min per API key
|
|
115
|
-
- Redis required for distributed enforcement
|
|
116
|
-
blocked: false
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
# {{task}}
|
|
120
|
-
|
|
121
|
-
**Status:** {{status}} ยท **Owner:** {{owner.name}} ({{owner.team}}) ยท **Priority:** {{priority}}
|
|
122
|
-
|
|
123
|
-
First note: {{notes[0]}}
|
|
124
|
-
|
|
125
|
-
## Notes
|
|
126
|
-
|
|
127
|
-
{{#each notes}}
|
|
128
|
-
- {{this}}
|
|
129
|
-
{{/each}}
|
|
130
|
-
|
|
131
|
-
{{#if blocked}}
|
|
132
|
-
โ ๏ธ This task is currently blocked.
|
|
133
|
-
{{else}}
|
|
134
|
-
โ
No blockers.
|
|
135
|
-
{{/if}}
|
|
124
|
+
resolvePath(data, "owner.name"); // โ 'Dana'
|
|
125
|
+
resolvePath(data, "notes[0]"); // โ 'Token bucket algorithm chosen over leaky bucket'
|
|
136
126
|
```
|
|
137
127
|
|
|
138
128
|
## License
|
|
139
129
|
|
|
140
|
-
|
|
130
|
+
Apache 2.0
|