astro-lilypond 0.16.1 → 0.16.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 CHANGED
@@ -3,7 +3,7 @@
3
3
  An [Astro](https://astro.build) integration for rendering [LilyPond](https://lilypond.org) music notation to images.
4
4
 
5
5
  - Render musical scores via Markdown or with an Astro component.
6
- - Works with remark, rehype and satteri Markdown processors out-of-the-box.
6
+ - Works with remark and satteri Markdown processors out-of-the-box.
7
7
  - Zero client-side JavaScript! Images are compiled at build time.
8
8
  - Automatic `alt` text generated from the score’s title and composer. (Or supply your own.)
9
9
  - Use the content loader to pass in a folder full of `.ly` files and get back an Astro content collection.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createComponent, renderComponent, renderTemplate, unescapeHTML, } from "astro/runtime/server/index.js";
2
2
  import emitAssetIntegration from "astro-emit-asset";
3
- import { rehypePlugin, remarkPlugin, satteriPlugin, } from "./plugins/index.js";
3
+ import { remarkPlugin, satteriPlugin, } from "./plugins/index.js";
4
4
  import { render as renderScore } from "./render.js";
5
5
  import { getRenderState, resolveAndSetRenderState } from "./renderState.js";
6
6
  import { altTextFor, emitLilypondAsset, emitLilypondPdfAsset, includePathsFor, lyTypeDeclarationsFor, parseLyHeaderFields, prependVersion, renderedHtml, resolveDefaults, sourceNameFor, titleFor, toLilypondMetadata, } from "./utils/index.js";
@@ -162,14 +162,10 @@ export default function lilypond(options = {}) {
162
162
  ...(existingOptions.remarkPlugins ?? []),
163
163
  [remarkPlugin, options],
164
164
  ],
165
- rehypePlugins: [
166
- ...(existingOptions.rehypePlugins ?? []),
167
- [rehypePlugin, options],
168
- ],
169
165
  }),
170
166
  },
171
167
  });
172
- logger?.info("astro-lilypond: registered unified remark/rehype plugins");
168
+ logger?.info("astro-lilypond: registered unified remark plugin");
173
169
  return;
174
170
  }
175
171
  throw new Error("astro-lilypond requires a processor-based Astro markdown config. " +
@@ -1,4 +1,3 @@
1
- export { rehypePlugin } from "./rehype.js";
2
1
  export { remarkPlugin } from "./remark.js";
3
2
  export { satteriPlugin } from "./satteri.js";
4
3
  export type { PluginOptions } from "./types.js";
@@ -1,3 +1,2 @@
1
- export { rehypePlugin } from "./rehype.js";
2
1
  export { remarkPlugin } from "./remark.js";
3
2
  export { satteriPlugin } from "./satteri.js";
@@ -3,9 +3,6 @@ import { altTextForBlock, emitLilypondAsset, includePathsFor, isLilypondLang, pr
3
3
  export function satteriPlugin(options) {
4
4
  return {
5
5
  name: "astro-lilypond",
6
- // Returning an mdast Html node (type: 'html') emits the value verbatim.
7
- // Sätteri's { rawHtml } escape hatch applies MDX brace-escaping which
8
- // would corrupt SVG content, so we use the plain html node form instead.
9
6
  async code(node, ctx) {
10
7
  if (!isLilypondLang(node.lang))
11
8
  return undefined;
@@ -34,10 +31,7 @@ export function satteriPlugin(options) {
34
31
  sourceName,
35
32
  }),
36
33
  });
37
- return {
38
- type: "html",
39
- value: renderedHtml(pages, alt),
40
- };
34
+ return { rawHtml: renderedHtml(pages, alt) };
41
35
  },
42
36
  };
43
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-lilypond",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "An Astro integration for rendering Lilypond markup to music notation.",
5
5
  "homepage": "https://lilypond.ky.fyi",
6
6
  "author": "Ky Decker",
@@ -50,12 +50,12 @@
50
50
  "unist-util-visit": "^5.1.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@astrojs/markdown-remark": "^7.2.1",
54
- "@astrojs/markdown-satteri": "^0.3.4",
53
+ "@astrojs/markdown-remark": "^7.2.2",
54
+ "@astrojs/markdown-satteri": "^0.3.5",
55
55
  "@types/mdast": "^4.0.4",
56
56
  "@types/node": "^26.1.1",
57
57
  "@vitest/coverage-v8": "^4.1.10",
58
- "astro": "^7.0.8",
58
+ "astro": "^7.1.6",
59
59
  "satteri": "^0.9.5",
60
60
  "typescript": "^7.0.2",
61
61
  "unified": "^11.0.5",
@@ -1,4 +0,0 @@
1
- import type { PluginOptions } from "./types.js";
2
- export declare function rehypePlugin(options: PluginOptions): (tree: any, file?: {
3
- path?: string;
4
- }) => Promise<void>;
@@ -1,65 +0,0 @@
1
- import { visit } from "unist-util-visit";
2
- import { defaultOptions, render } from "../render.js";
3
- import { altTextForBlock, emitLilypondAsset, includePathsFor, isLilypondLang, prependVersion, renderedHtml, resolveDefaults, sourceNameFor, titleFor, } from "../utils/index.js";
4
- // Typed loosely so it's assignable to both RehypePlugin and the unified
5
- // Plugin generic regardless of which @types/hast version the host project pins.
6
- export function rehypePlugin(options) {
7
- return async (tree, file) => {
8
- const promises = [];
9
- const includePaths = includePathsFor(file?.path);
10
- const sourceName = sourceNameFor(file?.path);
11
- const title = titleFor(sourceName);
12
- visit(tree, "element", (node, index, parent) => {
13
- if (node.tagName !== "pre" ||
14
- node.children?.length !== 1 ||
15
- node.children[0].type !== "element" ||
16
- node.children[0].tagName !== "code" ||
17
- index === undefined ||
18
- !parent)
19
- return;
20
- const codeNode = node.children[0];
21
- const cls = codeNode.properties?.className;
22
- if (!Array.isArray(cls))
23
- return;
24
- const lang = cls
25
- .find((c) => c.startsWith("language-"))
26
- ?.slice("language-".length);
27
- if (!isLilypondLang(lang))
28
- return;
29
- const raw = codeNode.children
30
- .filter((c) => c.type === "text")
31
- .map((c) => c.value)
32
- .join("");
33
- const { version, resolution, cropScale } = resolveDefaults(options.defaults);
34
- const source = version ? prependVersion(raw, version) : raw;
35
- const format = options.format ?? defaultOptions.format;
36
- const alt = altTextForBlock(codeNode.data?.meta, raw);
37
- const promise = emitLilypondAsset({
38
- title,
39
- format,
40
- source,
41
- resolution,
42
- crop: true,
43
- sizeScale: cropScale,
44
- binaryPath: options.binaryPath,
45
- render: () => render(source, {
46
- format,
47
- crop: true,
48
- defaults: options.defaults,
49
- timeout: options.timeout,
50
- binaryPath: options.binaryPath,
51
- includePaths,
52
- sourceName,
53
- }),
54
- }).then((pages) => {
55
- const rawNode = {
56
- type: "raw",
57
- value: renderedHtml(pages, alt),
58
- };
59
- parent.children[index] = rawNode;
60
- });
61
- promises.push(promise);
62
- });
63
- await Promise.all(promises);
64
- };
65
- }