@k-l-lambda/lilylet-markdown 0.1.60 → 0.1.64
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 +60 -4
- package/lib/index.cjs +5028 -0
- package/lib/index.d.cts +11 -0
- package/lib/index.js +4983 -180
- package/package.json +20 -10
package/README.md
CHANGED
|
@@ -17,18 +17,54 @@ npm install @k-l-lambda/lilylet-markdown
|
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
+
### CommonJS / Hexo
|
|
21
|
+
|
|
22
|
+
`require()` returns the plugin function directly; no `.default` adapter is needed:
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
const MarkdownIt = require('markdown-it');
|
|
26
|
+
const lilylet = require('@k-l-lambda/lilylet-markdown');
|
|
27
|
+
const md = new MarkdownIt().use(lilylet);
|
|
28
|
+
// Named helpers also live on the function:
|
|
29
|
+
const { prerender, initVerovio } = lilylet;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
ES modules continue to use the default plugin and named helper exports:
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import lilylet, { prerender, initVerovio } from '@k-l-lambda/lilylet-markdown';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For Hexo's `hexo-renderer-markdown-it`, register the package directly:
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
markdown:
|
|
42
|
+
plugins:
|
|
43
|
+
- '@k-l-lambda/lilylet-markdown'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Hexo must also pass Lilylet fences through its earlier syntax-highlighting
|
|
47
|
+
stage. The plugin supplies markup, not a browser player: client-side engraving
|
|
48
|
+
and audio playback still need a runtime.
|
|
49
|
+
|
|
50
|
+
Both module formats contain the Lilylet parser and MEI encoder. Consumers do
|
|
51
|
+
not load Lilylet's broad entry point, Lotus, or its unrelated decoder dependencies.
|
|
52
|
+
Verovio is imported only when `initVerovio()` is called. ESM and CommonJS may
|
|
53
|
+
coexist in one process without sharing a global parser registration.
|
|
54
|
+
|
|
20
55
|
### Basic Usage (Placeholder Mode)
|
|
21
56
|
|
|
22
|
-
|
|
57
|
+
Synchronous `md.render()` outputs placeholders containing the Lilylet source.
|
|
58
|
+
Call `await prerender(md, content)` first to embed MEI without a Verovio toolkit:
|
|
23
59
|
|
|
24
60
|
```javascript
|
|
25
61
|
import MarkdownIt from 'markdown-it';
|
|
26
|
-
import lilyletPlugin from '@k-l-lambda/lilylet-markdown';
|
|
62
|
+
import lilyletPlugin, { prerender } from '@k-l-lambda/lilylet-markdown';
|
|
27
63
|
|
|
28
64
|
const md = new MarkdownIt();
|
|
29
65
|
md.use(lilyletPlugin);
|
|
30
66
|
|
|
31
|
-
const
|
|
67
|
+
const content = `
|
|
32
68
|
# My Score
|
|
33
69
|
|
|
34
70
|
\`\`\`lilylet
|
|
@@ -36,7 +72,9 @@ const result = md.render(`
|
|
|
36
72
|
\\time 4/4
|
|
37
73
|
c'4 d' e' f' | g'1
|
|
38
74
|
\`\`\`
|
|
39
|
-
|
|
75
|
+
`;
|
|
76
|
+
await prerender(md, content);
|
|
77
|
+
const result = md.render(content);
|
|
40
78
|
```
|
|
41
79
|
|
|
42
80
|
Output:
|
|
@@ -117,6 +155,24 @@ c'4 d' e' f' | g'1
|
|
|
117
155
|
```
|
|
118
156
|
~~~
|
|
119
157
|
|
|
158
|
+
For a playable score, use `lyl.play` or `lilylet.play` as the fence language.
|
|
159
|
+
The plugin adds `data-playable`; your client runtime implements the controls
|
|
160
|
+
and audio. This attribute is retained after pre-rendering as well.
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm ci
|
|
166
|
+
npm test
|
|
167
|
+
npm pack
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The build emits ESM, CommonJS, and corresponding TypeScript declarations into
|
|
171
|
+
`lib/`. `prepack` builds these files before packing or publishing. The parser
|
|
172
|
+
and encoder are bundled from a pinned Lilylet build dependency; the generated
|
|
173
|
+
grammar is scoped locally to avoid collisions between entry points. No absolute
|
|
174
|
+
build-machine paths are required by the distributed package.
|
|
175
|
+
|
|
120
176
|
## Client-side Rendering
|
|
121
177
|
|
|
122
178
|
For client-side rendering, use the embedded MEI data:
|