@nuxtjs/mdc 0.11.0 → 0.12.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/module.d.mts CHANGED
@@ -69,6 +69,12 @@ interface MDCParseOptions {
69
69
  searchDepth?: number;
70
70
  };
71
71
  keepComments?: boolean;
72
+ /**
73
+ * Extract content heading from the markdown file.
74
+ *
75
+ * @default true
76
+ */
77
+ contentHeading?: boolean;
72
78
  /**
73
79
  * Inline mdc.config.ts
74
80
  */
package/dist/module.d.ts CHANGED
@@ -69,6 +69,12 @@ interface MDCParseOptions {
69
69
  searchDepth?: number;
70
70
  };
71
71
  keepComments?: boolean;
72
+ /**
73
+ * Extract content heading from the markdown file.
74
+ *
75
+ * @default true
76
+ */
77
+ contentHeading?: boolean;
72
78
  /**
73
79
  * Inline mdc.config.ts
74
80
  */
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
3
  "configKey": "mdc",
4
- "version": "0.11.0",
4
+ "version": "0.12.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -329,6 +329,8 @@ const module = defineNuxtModule({
329
329
  addImports({ from: resolver.resolve("./runtime/utils/node"), name: "flatUnwrap", as: "unwrapSlot" });
330
330
  addImports({ from: resolver.resolve("./runtime/parser"), name: "parseMarkdown", as: "parseMarkdown" });
331
331
  addServerImports([{ from: resolver.resolve("./runtime/parser"), name: "parseMarkdown", as: "parseMarkdown" }]);
332
+ addImports({ from: resolver.resolve("./runtime/stringify"), name: "stringifyMarkdown", as: "stringifyMarkdown" });
333
+ addServerImports([{ from: resolver.resolve("./runtime/stringify"), name: "stringifyMarkdown", as: "stringifyMarkdown" }]);
332
334
  if (options.components?.prose) {
333
335
  addComponentsDir({
334
336
  path: resolver.resolve("./runtime/components/prose"),
@@ -136,6 +136,7 @@ declare global {
136
136
  dir: any;
137
137
  };
138
138
  const __VLS_unref: typeof import('vue').unref;
139
+ const __VLS_placeholder: any;
139
140
  const __VLS_nativeElements: {
140
141
  a: HTMLAnchorElement;
141
142
  abbr: HTMLElement;
@@ -337,6 +338,11 @@ declare global {
337
338
  };
338
339
  } ? NonNullable<P> : never : T extends (props: infer P, ...args: any) => any ? P : {};
339
340
  type __VLS_IsFunction<T, K> = K extends keyof T ? __VLS_IsAny<T[K]> extends false ? unknown extends T[K] ? false : true : false : false;
341
+ type __VLS_NormalizeComponentEvent<Props, Events, onEvent extends keyof Props, Event extends keyof Events, CamelizedEvent extends keyof Events> = (__VLS_IsFunction<Props, onEvent> extends true ? Props : __VLS_IsFunction<Events, Event> extends true ? {
342
+ [K in onEvent]?: Events[Event];
343
+ } : __VLS_IsFunction<Events, CamelizedEvent> extends true ? {
344
+ [K in onEvent]?: Events[CamelizedEvent];
345
+ } : Props) & Record<string, unknown>;
340
346
  type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
341
347
  type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R ? U extends T ? never : __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R) : never;
342
348
  type __VLS_OverloadUnion<T> = Exclude<__VLS_OverloadUnionInner<(() => never) & T>, T extends () => never ? never : () => never>;
@@ -392,7 +398,6 @@ declare global {
392
398
  function __VLS_makeOptional<T>(t: T): {
393
399
  [K in keyof T]?: T[K];
394
400
  };
395
- function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
396
401
  function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K): T extends new (...args: any) => any ? (props: (K extends {
397
402
  $props: infer Props;
398
403
  } ? Props : any) & Record<string, unknown>, ctx?: any) => __VLS_Element & {
@@ -8,7 +8,15 @@ export function rehypeHighlight(opts) {
8
8
  const styles = [];
9
9
  visit(
10
10
  tree,
11
- (node) => ["pre", "code"].includes(node.tagName) && !!(node.properties?.language || node.properties?.highlights),
11
+ (_node) => {
12
+ const node = _node;
13
+ if (!["pre", "code"].includes(node.tagName)) {
14
+ return false;
15
+ }
16
+ const hasHighlightableLanguage = node.properties?.language !== void 0 && node.properties?.language !== "text";
17
+ const hasHighlightableLines = Boolean(node.properties?.highlights);
18
+ return hasHighlightableLanguage || hasHighlightableLines;
19
+ },
12
20
  (node) => {
13
21
  const _node = node;
14
22
  const highlights = typeof _node.properties.highlights === "string" ? _node.properties.highlights.split(/[,\s]+/).map(Number) : Array.isArray(_node.properties.highlights) ? _node.properties.highlights.map(Number) : [];
@@ -2,7 +2,7 @@ import { detab } from "detab";
2
2
  import { parseThematicBlock } from "./utils.js";
3
3
  export default (state, node) => {
4
4
  const lang = (node.lang || "") + " " + (node.meta || "");
5
- const { language, highlights, filename, meta } = parseThematicBlock(lang);
5
+ const { language = "text", highlights, filename, meta } = parseThematicBlock(lang);
6
6
  const value = node.value ? detab(node.value + "\n") : "";
7
7
  let result = {
8
8
  type: "element",
@@ -18,7 +18,7 @@ export default (state, node) => {
18
18
  state.patch(node, result);
19
19
  result = state.applyData(node, result);
20
20
  const properties = {
21
- language,
21
+ language: language || "text",
22
22
  filename,
23
23
  highlights,
24
24
  meta,
@@ -76,7 +76,7 @@ export const createMarkdownParser = async (inlineOptions = {}) => {
76
76
  const processedFile = await processor.process({ ...fileOptions, value: content, data: frontmatter });
77
77
  const result = processedFile.result;
78
78
  const data = Object.assign(
79
- contentHeading(result.body),
79
+ inlineOptions.contentHeading !== false ? contentHeading(result.body) : {},
80
80
  frontmatter,
81
81
  processedFile?.data || {}
82
82
  );
@@ -4,7 +4,7 @@ import { hasProtocol } from "ufo";
4
4
  import { toHtml } from "hast-util-to-html";
5
5
  import { visit } from "unist-util-visit";
6
6
  import { format } from "hast-util-format";
7
- import { computeHighlightRanges } from "./utils.js";
7
+ import { computeHighlightRanges, refineCodeLanguage } from "./utils.js";
8
8
  const mdcRemarkElementType = "mdc-element";
9
9
  const own = {}.hasOwnProperty;
10
10
  export function mdcRemark(options) {
@@ -123,7 +123,7 @@ const mdcRemarkHandlers = {
123
123
  }
124
124
  }
125
125
  if (attributes.language) {
126
- attributes.lang = attributes.language;
126
+ attributes.lang = refineCodeLanguage(attributes.language);
127
127
  delete attributes.language;
128
128
  }
129
129
  const result = { type: "inlineCode", value: nodeTextContent(node), attributes };
@@ -140,7 +140,7 @@ const mdcRemarkHandlers = {
140
140
  return {
141
141
  type: "code",
142
142
  value,
143
- lang: node.properties.language,
143
+ lang: refineCodeLanguage(node.properties.language),
144
144
  meta
145
145
  };
146
146
  },
@@ -1 +1,2 @@
1
1
  export declare function computeHighlightRanges(input: string[] | string): string;
2
+ export declare function refineCodeLanguage(language?: string): string;
@@ -14,3 +14,6 @@ export function computeHighlightRanges(input) {
14
14
  }
15
15
  return ranges.join(",");
16
16
  }
17
+ export function refineCodeLanguage(language) {
18
+ return String(language || "").trim();
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-modules/mdc",
6
6
  "license": "MIT",
@@ -71,13 +71,13 @@
71
71
  "test:watch": "vitest watch"
72
72
  },
73
73
  "dependencies": {
74
- "@nuxt/kit": "^3.14.1592",
75
- "@shikijs/transformers": "^1.24.1",
74
+ "@nuxt/kit": "^3.15.0",
75
+ "@shikijs/transformers": "^1.24.4",
76
76
  "@types/hast": "^3.0.4",
77
77
  "@types/mdast": "^4.0.4",
78
78
  "@vue/compiler-core": "^3.5.13",
79
- "consola": "^3.2.3",
80
- "debug": "^4.4.0",
79
+ "consola": "^3.3.3",
80
+ "debug": "4.4.0",
81
81
  "defu": "^6.1.4",
82
82
  "destr": "^2.0.3",
83
83
  "detab": "^3.0.2",
@@ -100,12 +100,12 @@
100
100
  "rehype-sort-attributes": "^5.0.1",
101
101
  "remark-emoji": "^5.0.1",
102
102
  "remark-gfm": "^4.0.0",
103
- "remark-mdc": "^3.5.0",
103
+ "remark-mdc": "^3.5.1",
104
104
  "remark-parse": "^11.0.0",
105
105
  "remark-rehype": "^11.1.1",
106
106
  "remark-stringify": "^11.0.0",
107
107
  "scule": "^1.3.0",
108
- "shiki": "^1.24.1",
108
+ "shiki": "^1.24.4",
109
109
  "ufo": "^1.5.4",
110
110
  "unified": "^11.0.5",
111
111
  "unist-builder": "^4.0.0",
@@ -115,26 +115,26 @@
115
115
  },
116
116
  "devDependencies": {
117
117
  "@nuxt/devtools": "latest",
118
- "@nuxt/eslint-config": "^0.7.2",
118
+ "@nuxt/eslint-config": "^0.7.4",
119
119
  "@nuxt/module-builder": "^0.8.4",
120
- "@nuxt/schema": "^3.14.1592",
120
+ "@nuxt/schema": "^3.15.0",
121
121
  "@nuxt/test-utils": "^3.15.1",
122
122
  "@nuxt/ui": "^2.20.0",
123
123
  "@nuxtjs/mdc": "link:.",
124
- "@types/node": "^22.10.1",
124
+ "@types/node": "^22.10.2",
125
125
  "changelogen": "^0.5.7",
126
- "eslint": "^9.16.0",
127
- "nuxt": "^3.14.1592",
126
+ "eslint": "^9.17.0",
127
+ "nuxt": "^3.15.0",
128
128
  "rehype": "^13.0.2",
129
- "release-it": "^17.10.0",
129
+ "release-it": "^17.11.0",
130
130
  "typescript": "5.6.3",
131
131
  "vitest": "^2.1.8",
132
- "vue-tsc": "^2.1.10"
132
+ "vue-tsc": "^2.2.0"
133
133
  },
134
134
  "resolutions": {
135
135
  "@nuxtjs/mdc": "workspace:*"
136
136
  },
137
- "packageManager": "pnpm@9.15.0",
137
+ "packageManager": "pnpm@9.15.2",
138
138
  "release-it": {
139
139
  "git": {
140
140
  "commitMessage": "chore(release): release v${version}"