astro-lilypond 0.3.4 → 0.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/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/rehype-plugin.d.ts.map +1 -1
- package/dist/rehype-plugin.js +9 -4
- package/dist/rehype-plugin.js.map +1 -1
- package/dist/remark-plugin.d.ts.map +1 -1
- package/dist/remark-plugin.js +9 -4
- package/dist/remark-plugin.js.map +1 -1
- package/dist/render.d.ts +8 -8
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +28 -30
- package/dist/render.js.map +1 -1
- package/dist/satteri-plugin.d.ts.map +1 -1
- package/dist/satteri-plugin.js +9 -4
- package/dist/satteri-plugin.js.map +1 -1
- package/dist/util.d.ts +2 -10
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +0 -6
- package/dist/util.js.map +1 -1
- package/package.json +15 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AstroIntegration } from "astro";
|
|
2
|
-
import type { LilypondPluginOptions
|
|
3
|
-
export type { OutputFormat };
|
|
2
|
+
import type { LilypondPluginOptions } from "./util.js";
|
|
4
3
|
export type { LilypondPluginOptions };
|
|
5
4
|
export interface LilypondOptions extends LilypondPluginOptions {
|
|
6
5
|
/**
|
|
@@ -14,10 +13,13 @@ export interface LilypondOptions extends LilypondPluginOptions {
|
|
|
14
13
|
* Output format. Defaults to `"svg"`.
|
|
15
14
|
*
|
|
16
15
|
* - `"svg"` — inline SVG embedded directly in the HTML (default)
|
|
17
|
-
* - `"png"` — `<img>` element with a base64 data URI
|
|
18
|
-
* - `{ type: "png", resolution: number }` — PNG at a specific DPI
|
|
16
|
+
* - `"png"` — `<img>` element with a base64 data URI
|
|
19
17
|
*/
|
|
20
|
-
format?:
|
|
18
|
+
format?: "svg" | "png";
|
|
19
|
+
/**
|
|
20
|
+
* Resolution in DPI (only applies to PNG). Defaults to `144`.
|
|
21
|
+
*/
|
|
22
|
+
resolution?: number;
|
|
21
23
|
/**
|
|
22
24
|
* Crop the output tightly to the content bounding box. Defaults to `true`.
|
|
23
25
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAS9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAS9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAMvD,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC7D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAqBD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,gBAAgB,CAiGhF"}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { promisify } from "util";
|
|
|
3
3
|
import { remarkLilypondPlugin } from "./remark-plugin.js";
|
|
4
4
|
import { rehypeLilypondPlugin } from "./rehype-plugin.js";
|
|
5
5
|
import { satteriLilypondPlugin } from "./satteri-plugin.js";
|
|
6
|
-
import { render } from "./render.js";
|
|
7
|
-
import { includePathsFor, prependVersion, renderToHtml
|
|
6
|
+
import { defaultOptions, render } from "./render.js";
|
|
7
|
+
import { includePathsFor, prependVersion, renderToHtml } from "./util.js";
|
|
8
8
|
const execFileAsync = promisify(execFile);
|
|
9
9
|
const LY_EXTENSIONS = [".ly", ".lilypond", ".ily"];
|
|
10
10
|
function lyFilePlugin(options) {
|
|
@@ -15,11 +15,11 @@ function lyFilePlugin(options) {
|
|
|
15
15
|
if (!LY_EXTENSIONS.some(ext => id.endsWith(ext)))
|
|
16
16
|
return;
|
|
17
17
|
const src = options.version ? prependVersion(source, options.version) : source;
|
|
18
|
-
const
|
|
18
|
+
const format = options.format ?? defaultOptions.format;
|
|
19
19
|
const buf = await render(src, {
|
|
20
20
|
format,
|
|
21
|
-
resolution,
|
|
22
|
-
crop: options.crop
|
|
21
|
+
resolution: options.resolution,
|
|
22
|
+
crop: options.crop,
|
|
23
23
|
includePaths: includePathsFor(id),
|
|
24
24
|
});
|
|
25
25
|
return { code: `export default ${JSON.stringify(renderToHtml(buf, format))}` };
|
|
@@ -53,7 +53,7 @@ export default function lilypond(options = {}) {
|
|
|
53
53
|
...existingOptions,
|
|
54
54
|
mdastPlugins: [
|
|
55
55
|
...(existingOptions.mdastPlugins ?? []),
|
|
56
|
-
satteriLilypondPlugin(
|
|
56
|
+
satteriLilypondPlugin(options),
|
|
57
57
|
],
|
|
58
58
|
}),
|
|
59
59
|
},
|
|
@@ -74,11 +74,11 @@ export default function lilypond(options = {}) {
|
|
|
74
74
|
...existingOptions,
|
|
75
75
|
remarkPlugins: [
|
|
76
76
|
...(existingOptions.remarkPlugins ?? []),
|
|
77
|
-
[remarkLilypondPlugin,
|
|
77
|
+
[remarkLilypondPlugin, options],
|
|
78
78
|
],
|
|
79
79
|
rehypePlugins: [
|
|
80
80
|
...(existingOptions.rehypePlugins ?? []),
|
|
81
|
-
[rehypeLilypondPlugin,
|
|
81
|
+
[rehypeLilypondPlugin, options],
|
|
82
82
|
],
|
|
83
83
|
}),
|
|
84
84
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG1E,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAU,CAAC;AA6B5D,SAAS,YAAY,CAAC,OAAwB;IAC7C,OAAO;QACN,IAAI,EAAE,+BAA+B;QACrC,OAAO,EAAE,KAAK;QACd,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE;YACzB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gB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AE;oCACd,GAAG,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC;oCACxC,CAAC,oBAAoB,EAAE,OAAO,CAAC;iCAC/B;6BACD,CAAC;yBACF;qBACD,CAAC,CAAC;oBACH,MAAM,EAAE,IAAI,CAAC,0DAA0D,CAAC,CAAC;oBACzE,OAAO;gBACR,CAAC;gBAED,MAAM,IAAI,KAAK,CACd,mEAAmE;oBAClE,gEAAgE;oBAChE,2EAA2E;oBAC3E,uBAAuB,iBAAiB,EAAE,IAAI,IAAI,MAAM,GAAG,CAC5D,CAAC;YACH,CAAC;YAED,mBAAmB,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;gBACxC,WAAW,CAAC;oBACX,QAAQ,EAAE,eAAe;oBACzB,OAAO,EAAE,aAAa;yBACpB,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAoB,GAAG,uDAAuD,CAAC;yBAC1F,IAAI,CAAC,IAAI,CAAC;iBACZ,CAAC,CAAC;YACJ,CAAC;SACD;KACD,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-plugin.d.ts","sourceRoot":"","sources":["../src/rehype-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAQvD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAKxD,wBAAgB,oBAAoB,CACnC,OAAO,GAAE,mBAAwB,GAC/B,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"rehype-plugin.d.ts","sourceRoot":"","sources":["../src/rehype-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAQvD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAKxD,wBAAgB,oBAAoB,CACnC,OAAO,GAAE,mBAAwB,GAC/B,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAqDxD"}
|
package/dist/rehype-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { visit } from "unist-util-visit";
|
|
2
|
-
import { render } from "./render.js";
|
|
3
|
-
import { includePathsFor, isLilypondLang, prependVersion, renderToHtml
|
|
2
|
+
import { defaultOptions, render } from "./render.js";
|
|
3
|
+
import { includePathsFor, isLilypondLang, prependVersion, renderToHtml } from "./util.js";
|
|
4
4
|
// Typed loosely so it's assignable to both RehypePlugin and the unified
|
|
5
5
|
// Plugin generic regardless of which @types/hast version the host project pins.
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -30,8 +30,13 @@ export function rehypeLilypondPlugin(options = {}) {
|
|
|
30
30
|
const source = options.version
|
|
31
31
|
? prependVersion(raw, options.version)
|
|
32
32
|
: raw;
|
|
33
|
-
const
|
|
34
|
-
const promise = render(source, {
|
|
33
|
+
const format = options.format ?? defaultOptions.format;
|
|
34
|
+
const promise = render(source, {
|
|
35
|
+
format,
|
|
36
|
+
resolution: options.resolution,
|
|
37
|
+
crop: options.crop,
|
|
38
|
+
includePaths,
|
|
39
|
+
})
|
|
35
40
|
.then((buf) => {
|
|
36
41
|
const rawNode = {
|
|
37
42
|
type: "raw",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-plugin.js","sourceRoot":"","sources":["../src/rehype-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"rehype-plugin.js","sourceRoot":"","sources":["../src/rehype-plugin.ts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O,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAExD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"remark-plugin.d.ts","sourceRoot":"","sources":["../src/remark-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,IAAI,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAExD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAkCrE,CAAC"}
|
package/dist/remark-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { visit } from "unist-util-visit";
|
|
2
|
-
import { render } from "./render.js";
|
|
3
|
-
import { includePathsFor, isLilypondLang, prependVersion, renderToHtml
|
|
2
|
+
import { defaultOptions, render } from "./render.js";
|
|
3
|
+
import { includePathsFor, isLilypondLang, prependVersion, renderToHtml } from "./util.js";
|
|
4
4
|
export const remarkLilypondPlugin = (options = {}) => {
|
|
5
5
|
return async (tree, file) => {
|
|
6
6
|
const promises = [];
|
|
@@ -11,8 +11,13 @@ export const remarkLilypondPlugin = (options = {}) => {
|
|
|
11
11
|
const source = options.version
|
|
12
12
|
? prependVersion(node.value, options.version)
|
|
13
13
|
: node.value;
|
|
14
|
-
const
|
|
15
|
-
const promise = render(source, {
|
|
14
|
+
const format = options.format ?? defaultOptions.format;
|
|
15
|
+
const promise = render(source, {
|
|
16
|
+
format,
|
|
17
|
+
resolution: options.resolution,
|
|
18
|
+
crop: options.crop,
|
|
19
|
+
includePaths,
|
|
20
|
+
})
|
|
16
21
|
.then((buf) => {
|
|
17
22
|
const htmlNode = {
|
|
18
23
|
type: "html",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-plugin.js","sourceRoot":"","sources":["../src/remark-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"remark-plugin.js","sourceRoot":"","sources":["../src/remark-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAK1F,MAAM,CAAC,MAAM,oBAAoB,GAAyC,CACzE,OAAO,GAAG,EAAE,EACX,EAAE;IACH,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAoB,EAAE,CAAC;QACrC,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM;gBAAE,OAAO;YAEzE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO;gBAC7B,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;gBAC7C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;YACd,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC;YAEvD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE;gBAC9B,MAAM;gBACN,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,YAAY;aACZ,CAAC;iBACA,IAAI,CAAC,CAAC,GAAG,EAAQ,EAAE;gBACnB,MAAM,QAAQ,GAAS;oBACtB,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC;iBAChC,CAAC;gBACF,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;YACnC,CAAC,CAAC,CAAC;YAEJ,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACH,CAAC,CAAC"}
|
package/dist/render.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
declare const FORMATS: readonly ["png", "svg"];
|
|
2
|
+
export type Format = (typeof FORMATS)[number];
|
|
2
3
|
export interface RenderOptions {
|
|
3
4
|
/** Output format. Defaults to `"svg"`. */
|
|
4
5
|
format?: Format;
|
|
@@ -7,19 +8,18 @@ export interface RenderOptions {
|
|
|
7
8
|
/** Path to the `lilypond` binary. Defaults to `"lilypond"`. */
|
|
8
9
|
binaryPath?: string;
|
|
9
10
|
/**
|
|
10
|
-
* Crop the output
|
|
11
|
-
*
|
|
11
|
+
* Crop the output tightly to the content bounding box.
|
|
12
|
+
* Disable if full-page renders are preferred.
|
|
13
|
+
* Defaults to `true`.
|
|
12
14
|
*/
|
|
13
15
|
crop?: boolean;
|
|
14
16
|
/**
|
|
15
|
-
* Extra directories LilyPond should search for `\include`d files
|
|
16
|
-
*
|
|
17
|
-
* containing the source `.ly`/Markdown file, so sibling
|
|
18
|
-
* `\include "foo.ily"` files resolve even though rendering happens in a
|
|
19
|
-
* temp directory.
|
|
17
|
+
* Extra directories LilyPond should search for `\include`d files.
|
|
18
|
+
* Typically the directory containing the source `.ly`/Markdown file.
|
|
20
19
|
*/
|
|
21
20
|
includePaths?: string[];
|
|
22
21
|
}
|
|
23
22
|
export declare const defaultOptions: Required<Omit<RenderOptions, "includePaths">>;
|
|
24
23
|
export declare function render(source: string, options?: RenderOptions): Promise<Buffer>;
|
|
24
|
+
export {};
|
|
25
25
|
//# sourceMappingURL=render.d.ts.map
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,OAAO,YAAI,KAAK,EAAE,KAAK,CAAU,CAAC;AAExC,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC7B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAKxE,CAAC;AAEF,wBAAsB,MAAM,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,aAAkB,GACzB,OAAO,CAAC,MAAM,CAAC,CAiEjB"}
|
package/dist/render.js
CHANGED
|
@@ -4,22 +4,7 @@ import { join } from "path";
|
|
|
4
4
|
import { tmpdir } from "os";
|
|
5
5
|
import { promisify } from "util";
|
|
6
6
|
const execFileAsync = promisify(execFile);
|
|
7
|
-
|
|
8
|
-
// still produces valid output (it logs "continuing, cross fingers" and exits
|
|
9
|
-
// zero). Complex real-world scores with cross-staff spacing can legitimately
|
|
10
|
-
// trigger this, so it shouldn't fail the build on its own.
|
|
11
|
-
const BENIGN_STDERR_RE = /^programming error:.*\n^continuing, cross fingers$/gm;
|
|
12
|
-
function isBenignStderr(stderr) {
|
|
13
|
-
return stderr.replace(BENIGN_STDERR_RE, "").trim() === "";
|
|
14
|
-
}
|
|
15
|
-
const FORMAT_FLAGS = {
|
|
16
|
-
midi: null,
|
|
17
|
-
pdf: "--pdf",
|
|
18
|
-
png: "--png",
|
|
19
|
-
ps: "--ps",
|
|
20
|
-
svg: "--svg",
|
|
21
|
-
eps: "--eps",
|
|
22
|
-
};
|
|
7
|
+
const FORMATS = ["png", "svg"];
|
|
23
8
|
export const defaultOptions = {
|
|
24
9
|
format: "svg",
|
|
25
10
|
resolution: 144,
|
|
@@ -28,9 +13,8 @@ export const defaultOptions = {
|
|
|
28
13
|
};
|
|
29
14
|
export async function render(source, options = {}) {
|
|
30
15
|
const { format = defaultOptions.format, resolution = defaultOptions.resolution, binaryPath = defaultOptions.binaryPath, crop = defaultOptions.crop, includePaths = [], } = options;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
throw new Error(`${opts.format} is not a supported format`);
|
|
16
|
+
if (!FORMATS.includes(format)) {
|
|
17
|
+
throw new Error(`${format} is not a supported format`);
|
|
34
18
|
}
|
|
35
19
|
const dir = await mkdtemp(join(tmpdir(), "astro-lilypond-"));
|
|
36
20
|
const inputPath = join(dir, "input.ly");
|
|
@@ -38,29 +22,43 @@ export async function render(source, options = {}) {
|
|
|
38
22
|
try {
|
|
39
23
|
await writeFile(inputPath, source, "utf8");
|
|
40
24
|
const args = [
|
|
41
|
-
|
|
42
|
-
`--
|
|
25
|
+
// Render the correct format
|
|
26
|
+
`--format=${format}`,
|
|
27
|
+
// Define defaults — these can be overridden with the appropriate flags
|
|
28
|
+
// inside of individual .ly files
|
|
29
|
+
// Disable point-and-click behavior on SVGs when clicking noteheads
|
|
43
30
|
"--define-default=no-point-and-click",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"--
|
|
31
|
+
// Use the `cairo` backend for graphics rendering; faster than the default `ps` backend
|
|
32
|
+
// https://lilypond.org/doc/v2.26/Documentation/usage/advanced-command_002dline-options-for-lilypond
|
|
33
|
+
"--define-default=backend=cairo",
|
|
34
|
+
// Resolution for generating PNGs (set in DPI)
|
|
35
|
+
`--define-default=resolution=${resolution}`,
|
|
36
|
+
// Set cropping
|
|
37
|
+
`--define-default=crop=${crop ? "#t" : "#f"}`,
|
|
38
|
+
// If the LilyPond file imports from others via \include, make sure those files are included
|
|
39
|
+
...includePaths.map((p) => `--include=${p}`),
|
|
47
40
|
"--output",
|
|
48
41
|
outputBase,
|
|
49
42
|
inputPath,
|
|
50
|
-
]
|
|
43
|
+
];
|
|
44
|
+
// LilyPond writes its progress log, and any warnings/errors, to stderr
|
|
45
|
+
// even on success — surface it in the build output so it's visible,
|
|
46
|
+
// but let the exit code (not stderr content) decide pass/fail.
|
|
51
47
|
let stderr;
|
|
52
48
|
try {
|
|
53
|
-
({ stderr } = await execFileAsync(
|
|
49
|
+
({ stderr } = await execFileAsync(binaryPath, args));
|
|
54
50
|
}
|
|
55
51
|
catch (err) {
|
|
56
52
|
const errStderr = err && typeof err === "object" && "stderr" in err
|
|
57
53
|
? String(err.stderr)
|
|
58
54
|
: undefined;
|
|
55
|
+
if (errStderr)
|
|
56
|
+
process.stderr.write(errStderr);
|
|
59
57
|
throw new Error(errStderr || (err instanceof Error ? err.message : String(err)));
|
|
60
58
|
}
|
|
61
|
-
if (stderr
|
|
62
|
-
|
|
63
|
-
return await readOutputFile(outputBase,
|
|
59
|
+
if (stderr)
|
|
60
|
+
process.stderr.write(stderr);
|
|
61
|
+
return await readOutputFile(outputBase, format, crop);
|
|
64
62
|
}
|
|
65
63
|
finally {
|
|
66
64
|
await rm(dir, { recursive: true, force: true });
|
|
@@ -77,7 +75,7 @@ async function readOutputFile(base, format, crop) {
|
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
// Regular output: single page → <base>.<format>, multi-page →
|
|
80
|
-
// <base>-1.<format> (svg
|
|
78
|
+
// <base>-1.<format> (svg) or <base>-page1.<format> (png).
|
|
81
79
|
try {
|
|
82
80
|
return await readFile(`${base}.${format}`);
|
|
83
81
|
}
|
package/dist/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,OAAO,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AAQ,CAAC,GAAG,IAAI,YAAY,MAAM,EAAE,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACd,8BAA8B,IAAI,YAAY,MAAM,0BACnD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAChD,EAAE,CACF,CAAC;QACH,CAAC;IACF,CAAC;IAED,8DAA8D;IAC9D,0DAA0D;IAC1D,IAAI,CAAC;QACJ,OAAO,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACR,IAAI,CAAC;YACJ,OAAO,MAAM,QAAQ,CAAC,GAAG,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,MAAM,QAAQ,CAAC,GAAG,IAAI,UAAU,MAAM,EAAE,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"satteri-plugin.d.ts","sourceRoot":"","sources":["../src/satteri-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,qBAAqB,EAErB,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAEzD,wBAAgB,qBAAqB,CACpC,OAAO,GAAE,oBAAyB,GAChC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"satteri-plugin.d.ts","sourceRoot":"","sources":["../src/satteri-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,qBAAqB,EAErB,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAEzD,wBAAgB,qBAAqB,CACpC,OAAO,GAAE,oBAAyB,GAChC,qBAAqB,CAyBvB"}
|
package/dist/satteri-plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { render } from "./render.js";
|
|
2
|
-
import { includePathsFor, isLilypondLang, prependVersion, renderToHtml
|
|
1
|
+
import { defaultOptions, render } from "./render.js";
|
|
2
|
+
import { includePathsFor, isLilypondLang, prependVersion, renderToHtml } from "./util.js";
|
|
3
3
|
export function satteriLilypondPlugin(options = {}) {
|
|
4
4
|
return {
|
|
5
5
|
name: "astro-lilypond",
|
|
@@ -12,9 +12,14 @@ export function satteriLilypondPlugin(options = {}) {
|
|
|
12
12
|
const source = options.version
|
|
13
13
|
? prependVersion(node.value, options.version)
|
|
14
14
|
: node.value;
|
|
15
|
-
const
|
|
15
|
+
const format = options.format ?? defaultOptions.format;
|
|
16
16
|
const includePaths = includePathsFor(ctx.fileURL);
|
|
17
|
-
const buf = await render(source, {
|
|
17
|
+
const buf = await render(source, {
|
|
18
|
+
format,
|
|
19
|
+
resolution: options.resolution,
|
|
20
|
+
crop: options.crop,
|
|
21
|
+
includePaths,
|
|
22
|
+
});
|
|
18
23
|
return { type: "html", value: renderToHtml(buf, format) };
|
|
19
24
|
},
|
|
20
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"satteri-plugin.js","sourceRoot":"","sources":["../src/satteri-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"satteri-plugin.js","sourceRoot":"","sources":["../src/satteri-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAK1F,MAAM,UAAU,qBAAqB,CACpC,OAAO,GAAyB,EAAE;IAElC,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,wEAAwE;QACxE,sEAAsE;QACtE,yEAAyE;QACzE,KAAK,CAAC,IAAI,CACT,IAAoB,EACpB,GAAwB;YAExB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,OAAO,SAAS,CAAC;YACjD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO;gBAC7B,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;gBAC7C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;YACd,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC;YACvD,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE;gBAChC,MAAM;gBACN,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,YAAY;aACZ,CAAC,CAAC;YACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;QAC3D,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
export type OutputFormat = "svg" | "png" | {
|
|
2
|
-
type: "png";
|
|
3
|
-
resolution: number;
|
|
4
|
-
};
|
|
5
1
|
export interface LilypondPluginOptions {
|
|
6
2
|
version?: string;
|
|
7
|
-
format?:
|
|
3
|
+
format?: "svg" | "png";
|
|
4
|
+
resolution?: number;
|
|
8
5
|
crop?: boolean;
|
|
9
6
|
}
|
|
10
7
|
/** Returns true for the fenced-block language identifiers that trigger SVG rendering. */
|
|
11
8
|
export declare function isLilypondLang(lang: string | null | undefined): boolean;
|
|
12
|
-
/** Normalises an OutputFormat value into a plain format string and optional resolution (DPI). */
|
|
13
|
-
export declare function resolveFormat(format: OutputFormat): {
|
|
14
|
-
format: "svg" | "png";
|
|
15
|
-
resolution?: number;
|
|
16
|
-
};
|
|
17
9
|
/**
|
|
18
10
|
* If `version` is provided and the source doesn't already declare `\version`,
|
|
19
11
|
* prepend `\version "X.X.X"` so users don't need to write it manually.
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAGA,MAAM,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,qBAAqB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGtE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAAE,CAIjF;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAMvE"}
|
package/dist/util.js
CHANGED
|
@@ -4,12 +4,6 @@ import { fileURLToPath } from "url";
|
|
|
4
4
|
export function isLilypondLang(lang) {
|
|
5
5
|
return lang === "lilypond" || lang === "ly" || lang === "ily";
|
|
6
6
|
}
|
|
7
|
-
/** Normalises an OutputFormat value into a plain format string and optional resolution (DPI). */
|
|
8
|
-
export function resolveFormat(format) {
|
|
9
|
-
if (typeof format === "string")
|
|
10
|
-
return { format };
|
|
11
|
-
return { format: format.type, resolution: format.resolution };
|
|
12
|
-
}
|
|
13
7
|
/**
|
|
14
8
|
* If `version` is provided and the source doesn't already declare `\version`,
|
|
15
9
|
* prepend `\version "X.X.X"` so users don't need to write it manually.
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AASpC,yFAAyF;AACzF,MAAM,UAAU,cAAc,CAAC,IAA+B;IAC7D,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,OAAe;IAC7D,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,OAAO,cAAc,OAAO,MAAM,MAAM,EAAE,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuC;IACtE,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACxB,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,MAAqB;IAC9D,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,oDAAoD,GAAG,4BAA4B,CAAC;IAC5F,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;AACzE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-lilypond",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "An Astro integration for rendering Lilypond
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "An Astro integration for rendering Lilypond markup to music notation.",
|
|
5
|
+
"homepage": "https://lilypond.ky.fyi",
|
|
6
|
+
"author": "Ky Decker",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/kydecker/astro-lilypond"
|
|
11
|
+
},
|
|
5
12
|
"type": "module",
|
|
6
13
|
"main": "./dist/index.js",
|
|
7
14
|
"types": "./dist/index.d.ts",
|
|
@@ -24,15 +31,14 @@
|
|
|
24
31
|
"images",
|
|
25
32
|
"lilypond",
|
|
26
33
|
"markdown",
|
|
34
|
+
"media",
|
|
27
35
|
"music",
|
|
28
|
-
"
|
|
36
|
+
"renderer",
|
|
37
|
+
"score",
|
|
38
|
+
"tooling",
|
|
39
|
+
"withastro",
|
|
40
|
+
"utils"
|
|
29
41
|
],
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "https://github.com/kydecker/astro-lilypond"
|
|
33
|
-
},
|
|
34
|
-
"author": "Ky Decker",
|
|
35
|
-
"license": "MIT",
|
|
36
42
|
"peerDependencies": {
|
|
37
43
|
"astro": ">=7.0.0"
|
|
38
44
|
},
|