prettier-plugin-mdc 0.2.0 → 0.2.1

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.mts CHANGED
@@ -11,6 +11,6 @@ declare const parsers: Record<typeof AST_FORMAT, Parser<Node>>;
11
11
  declare const printers: Record<typeof AST_FORMAT, Printer<Node>>;
12
12
  //#endregion
13
13
  //#region src/index.d.ts
14
- declare const languages: Partial<SupportLanguage>[];
14
+ declare const languages: SupportLanguage[];
15
15
  //#endregion
16
16
  export { languages, parsers, printers };
package/dist/index.mjs CHANGED
@@ -311,7 +311,7 @@ const { hardline } = doc.builders;
311
311
  const mdastPrinter = markdown$1.printers.mdast;
312
312
  function extractYamlContent(rawData) {
313
313
  if (!rawData) return;
314
- return rawData.trimEnd().slice(1, -3).trimEnd() || void 0;
314
+ return rawData.trimEnd().slice(1).replace(/\s-+$/, "").trimEnd() || void 0;
315
315
  }
316
316
  const printers = { [AST_FORMAT]: {
317
317
  ...mdastPrinter,
@@ -319,12 +319,15 @@ const printers = { [AST_FORMAT]: {
319
319
  if (mdcNodeTypes.includes(node.type)) return visitorKeys[node.type];
320
320
  return mdastPrinter.getVisitorKeys(node, nonTraversableKeys);
321
321
  },
322
- embed(path) {
322
+ embed(path, options) {
323
323
  const { node } = path;
324
324
  if (isYamlNode(node)) return async (textToDoc) => {
325
325
  let yamlDoc;
326
326
  try {
327
- yamlDoc = await textToDoc(node.value, { parser: "yaml" });
327
+ yamlDoc = await textToDoc(node.value, {
328
+ ...options,
329
+ parser: "yaml"
330
+ });
328
331
  } catch {
329
332
  yamlDoc = node.value;
330
333
  }
@@ -333,20 +336,22 @@ const printers = { [AST_FORMAT]: {
333
336
  hardline,
334
337
  yamlDoc,
335
338
  hardline,
336
- "---",
337
- hardline
339
+ "---"
338
340
  ];
339
341
  };
340
342
  if (isContainerComponentNode(node) && node.rawData) {
341
343
  const yamlContent = extractYamlContent(node.rawData);
342
- if (yamlContent) return async (textToDoc, print, _path, options) => {
344
+ if (yamlContent) return async (textToDoc, print, _path, options$1) => {
343
345
  let yamlDoc;
344
346
  try {
345
- yamlDoc = await textToDoc(yamlContent, { parser: "yaml" });
347
+ yamlDoc = await textToDoc(yamlContent, {
348
+ ...options$1,
349
+ parser: "yaml"
350
+ });
346
351
  } catch {
347
352
  yamlDoc = yamlContent;
348
353
  }
349
- return printContainerComponentWithYamlDoc(path, print, options, [
354
+ return printContainerComponentWithYamlDoc(path, print, options$1, [
350
355
  "---",
351
356
  hardline,
352
357
  yamlDoc,
@@ -356,7 +361,7 @@ const printers = { [AST_FORMAT]: {
356
361
  ]);
357
362
  };
358
363
  }
359
- return null;
364
+ return mdastPrinter.embed(path, options);
360
365
  },
361
366
  print(path, options, print) {
362
367
  const { node } = path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-mdc",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "author": "Ray <i@mk1.io> (@so1ve)",
5
5
  "type": "module",
6
6
  "description": "Prettier plugin for MDC syntax",
@@ -64,7 +64,7 @@
64
64
  "vitest": "^4.0.16"
65
65
  },
66
66
  "peerDependencies": {
67
- "prettier": "~3.6.2"
67
+ "prettier": ">=3.6.0"
68
68
  },
69
69
  "scripts": {
70
70
  "build": "tsdown",