mdeval 1.3.1 → 1.4.0
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 +66 -0
- package/package.json +1 -1
- package/skills/mdeval/SKILL.md +31 -0
package/README.md
CHANGED
|
@@ -9,6 +9,9 @@ mdeval embeds JavaScript directly in your Markdown using HTML comments. The logi
|
|
|
9
9
|
|
|
10
10
|
Any value that matters — a dependency count, a version string, a benchmark result — is computed, not typed. Whether written by a person or an AI agent, the expression shows the work and anyone can verify it. Re-run `mdeval` and every value updates.
|
|
11
11
|
|
|
12
|
+
> [!TIP]
|
|
13
|
+
> Particularly useful for **knowledge bases** — contact lists, project trackers, changelogs, or any Markdown that functions as a source of truth. Values stay accurate on every run, so nothing drifts. AI agents reading the files also benefit: pre-computed values mean they don't need to re-process raw data across multiple documents, cutting token usage significantly.
|
|
14
|
+
|
|
12
15
|
## Install
|
|
13
16
|
|
|
14
17
|
```bash
|
|
@@ -46,6 +49,69 @@ The file is updated in-place. You can pass multiple files or glob patterns: `mde
|
|
|
46
49
|
|
|
47
50
|
`node_modules` and hidden directories are automatically excluded from glob expansion.
|
|
48
51
|
|
|
52
|
+
## Example
|
|
53
|
+
|
|
54
|
+
**`CONTACTS.md`** — a contact list stored as data, rendered as a table when viewed:
|
|
55
|
+
|
|
56
|
+
````markdown
|
|
57
|
+
<!--mdeval
|
|
58
|
+
import { table, link } from 'md-pen';
|
|
59
|
+
|
|
60
|
+
export const contacts = [
|
|
61
|
+
{
|
|
62
|
+
name: 'Alice Martin',
|
|
63
|
+
linkedin: 'https://linkedin.com/in/alice-martin',
|
|
64
|
+
notes: 'Met at JSConf 2023',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'Bob Tanaka',
|
|
68
|
+
linkedin: 'https://linkedin.com/in/bob-tanaka',
|
|
69
|
+
notes: 'Former colleague at Acme Co.',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
export const findContact = name => contacts.find(c => c.name === name);
|
|
74
|
+
|
|
75
|
+
const contactsTable = table(
|
|
76
|
+
contacts.map(({ name, linkedin, notes }) => ({ Name: link(linkedin, name), Notes: notes })),
|
|
77
|
+
);
|
|
78
|
+
-->
|
|
79
|
+
|
|
80
|
+
<!--mdeval block(contactsTable)-->
|
|
81
|
+
| Name | Notes |
|
|
82
|
+
| - | - |
|
|
83
|
+
| [Alice Martin](https://linkedin.com/in/alice-martin) | Met at JSConf 2023 |
|
|
84
|
+
| [Bob Tanaka](https://linkedin.com/in/bob-tanaka) | Former colleague at Acme Co. |
|
|
85
|
+
<!--/mdeval-->
|
|
86
|
+
````
|
|
87
|
+
|
|
88
|
+
**`TIMELINE.md`** — imports contacts and links them by LinkedIn:
|
|
89
|
+
|
|
90
|
+
````markdown
|
|
91
|
+
<!--mdeval
|
|
92
|
+
import { link, ul, bold } from 'md-pen';
|
|
93
|
+
|
|
94
|
+
// Imports from the mdeval block!
|
|
95
|
+
import { findContact } from './CONTACTS.md';
|
|
96
|
+
|
|
97
|
+
const events = [
|
|
98
|
+
{ date: '2023-10-15', description: 'Attended JSConf 2023' },
|
|
99
|
+
{ date: '2024-03-01', description: `Coffee with ${link(findContact('Alice Martin').linkedin, 'Alice Martin')}` },
|
|
100
|
+
{ date: '2024-11-08', description: 'Started new open-source project' },
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
const list = ul(events.map(({ date, description }) => `${bold(date)} — ${description}`));
|
|
104
|
+
-->
|
|
105
|
+
|
|
106
|
+
<!--mdeval block(list)-->
|
|
107
|
+
- __2023-10-15__ — Attended JSConf 2023
|
|
108
|
+
- __2024-03-01__ — Coffee with [Alice Martin](https://linkedin.com/in/alice-martin)
|
|
109
|
+
- __2024-11-08__ — Started new open-source project
|
|
110
|
+
<!--/mdeval-->
|
|
111
|
+
````
|
|
112
|
+
|
|
113
|
+
The source of truth for contacts live in `CONTACTS.md`. If contact info changes, run `mdeval **/*.md` and all files get re-rendered with the latest data.
|
|
114
|
+
|
|
49
115
|
## Notes
|
|
50
116
|
|
|
51
117
|
- A file can have **multiple script blocks** — they're merged into one module, so variables and imports are shared. We recommend placing them at the top to signal the file has generated content.
|
package/package.json
CHANGED
package/skills/mdeval/SKILL.md
CHANGED
|
@@ -150,6 +150,37 @@ const x = String.fromCharCode(45, 45, 62);
|
|
|
150
150
|
|
|
151
151
|
**Use IIFEs to co-locate logic.** In large docs, keep marker-specific computation inline instead of in a distant script block: `<!--mdeval (() => { ... })()-->`.
|
|
152
152
|
|
|
153
|
+
**Standalone markers suppress inline markdown in the value.** When a marker opens a line — standalone paragraph, list item, or blockquote — GitHub treats the entire line as a raw HTML block. Inline markdown in the value (`` `code` ``, `**bold**`, `[link](url)`) is not processed and appears literally.
|
|
154
|
+
|
|
155
|
+
````markdown
|
|
156
|
+
<!-- ❌ backtick shows literally — line is an HTML block, not inline markdown -->
|
|
157
|
+
<!--mdeval expr-->`value`<!--/mdeval-->
|
|
158
|
+
````
|
|
159
|
+
|
|
160
|
+
Use a multi-line marker so the value occupies its own lines, which are processed as normal markdown. Use [md-pen](https://github.com/privatenumber/md-pen) to generate formatted values:
|
|
161
|
+
|
|
162
|
+
````markdown
|
|
163
|
+
<!--mdeval
|
|
164
|
+
import { code, bold, link } from 'md-pen';
|
|
165
|
+
-->
|
|
166
|
+
|
|
167
|
+
<!--mdeval code('asdf')-->
|
|
168
|
+
`asdf`
|
|
169
|
+
<!--/mdeval-->
|
|
170
|
+
````
|
|
171
|
+
|
|
172
|
+
Markers inside headings are always inline — markdown in the value always renders there.
|
|
173
|
+
|
|
174
|
+
**Comments don't work in link URLs or image alt text.** GitHub escapes comment syntax in these positions:
|
|
175
|
+
|
|
176
|
+
````markdown
|
|
177
|
+
<!-- ❌ comment is URL-encoded as href -->
|
|
178
|
+
[text](<!-- comment -->)
|
|
179
|
+
|
|
180
|
+
<!-- ❌ comment appears as visible alt text -->
|
|
181
|
+

|
|
182
|
+
````
|
|
183
|
+
|
|
153
184
|
**Markers in code blocks are safe.** Fenced, indented, and inline code won't be touched — safe to document mdeval syntax in your own README.
|
|
154
185
|
|
|
155
186
|
**Never create a .md file with only a script block and no real content.** Markdown files must contain actual prose/documentation. For shared logic or utilities, create a `.js` or `.ts` file and import it from your markdown instead.
|