astro-lilypond 1.1.1 → 1.1.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.
Files changed (2) hide show
  1. package/dist/index.js +14 -34
  2. package/package.json +8 -2
package/dist/index.js CHANGED
@@ -106,6 +106,13 @@ export const Score = createComponent(async (result, props) => {
106
106
  const { Score: ContentScore } = await getScore(content, { format, crop });
107
107
  return renderTemplate `${renderComponent(result, "Score", ContentScore, imageProps)}`;
108
108
  });
109
+ function injectMarkdownPlugin(processor, key, plugin) {
110
+ if (!processor.options) {
111
+ processor.options = {};
112
+ }
113
+ const options = processor.options;
114
+ options[key] = [...(options[key] ?? []), plugin];
115
+ }
109
116
  function lyFilePlugin(options) {
110
117
  return {
111
118
  name: "vite-plugin-astro-lilypond-ly",
@@ -164,44 +171,17 @@ export default function lilypond(options = {}) {
164
171
  });
165
172
  const existingProcessor = config.markdown?.processor;
166
173
  if (existingProcessor?.name === "satteri") {
167
- const { satteri, isSatteriProcessor } = await import("@astrojs/markdown-satteri");
168
- if (!isSatteriProcessor(existingProcessor)) {
169
- throw new Error("astro-lilypond: the active markdown processor reports the name " +
170
- '"satteri" but failed the isSatteriProcessor check.');
171
- }
172
- const existingOptions = existingProcessor.options ?? {};
173
- updateConfig({
174
- markdown: {
175
- processor: satteri({
176
- ...existingOptions,
177
- mdastPlugins: [
178
- ...(existingOptions.mdastPlugins ?? []),
179
- satteriPlugin(options),
180
- ],
181
- }),
182
- },
183
- });
174
+ injectMarkdownPlugin(existingProcessor, "mdastPlugins", satteriPlugin(options));
175
+ updateConfig({ markdown: { processor: existingProcessor } });
184
176
  logger?.info("Registered Sätteri mdast plugin");
185
177
  return;
186
178
  }
187
179
  if (existingProcessor?.name === "unified") {
188
- const { unified, isUnifiedProcessor } = await import("@astrojs/markdown-remark");
189
- if (!isUnifiedProcessor(existingProcessor)) {
190
- throw new Error("astro-lilypond: the active markdown processor reports the name " +
191
- '"unified" but failed the isUnifiedProcessor check.');
192
- }
193
- const existingOptions = existingProcessor.options ?? {};
194
- updateConfig({
195
- markdown: {
196
- processor: unified({
197
- ...existingOptions,
198
- remarkPlugins: [
199
- ...(existingOptions.remarkPlugins ?? []),
200
- [remarkPlugin, options],
201
- ],
202
- }),
203
- },
204
- });
180
+ injectMarkdownPlugin(existingProcessor, "remarkPlugins", [
181
+ remarkPlugin,
182
+ options,
183
+ ]);
184
+ updateConfig({ markdown: { processor: existingProcessor } });
205
185
  logger?.info("Registered unified remark plugin");
206
186
  return;
207
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-lilypond",
3
- "version": "1.1.1",
3
+ "version": "1.1.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",
@@ -46,7 +46,13 @@
46
46
  "utils"
47
47
  ],
48
48
  "peerDependencies": {
49
- "astro": ">=7.0.0"
49
+ "astro": ">=7.0.0",
50
+ "@astrojs/markdown-remark": ">=7.0.0"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "@astrojs/markdown-remark": {
54
+ "optional": true
55
+ }
50
56
  },
51
57
  "dependencies": {
52
58
  "astro-emit-asset": "^0.1.4",