@nuxtjs/mdc 0.18.3 → 0.19.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
@@ -104,10 +104,16 @@ interface MDCStringifyOptions {
104
104
  options?: YamlToStringOptions;
105
105
  };
106
106
  plugins?: {
107
- remarkStringify?: {
107
+ 'remarkStringify'?: {
108
108
  options?: Options$1;
109
109
  };
110
- remarkMDC?: {
110
+ /**
111
+ * @deprecated use 'remark-mdc' instead
112
+ */
113
+ 'remarkMDC'?: {
114
+ options?: RemarkMDCOptions;
115
+ };
116
+ 'remark-mdc'?: {
111
117
  options?: RemarkMDCOptions;
112
118
  };
113
119
  };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
3
  "configKey": "mdc",
4
- "version": "0.18.3",
4
+ "version": "0.19.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,7 +1,7 @@
1
1
  import type { PropType } from 'vue';
2
- declare var __VLS_7: {};
2
+ declare var __VLS_8: {};
3
3
  type __VLS_Slots = {} & {
4
- default?: (props: typeof __VLS_7) => any;
4
+ default?: (props: typeof __VLS_8) => any;
5
5
  };
6
6
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
7
  href: {
@@ -1,7 +1,7 @@
1
1
  import type { PropType } from 'vue';
2
- declare var __VLS_7: {};
2
+ declare var __VLS_8: {};
3
3
  type __VLS_Slots = {} & {
4
- default?: (props: typeof __VLS_7) => any;
4
+ default?: (props: typeof __VLS_8) => any;
5
5
  };
6
6
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
7
  href: {
@@ -8,7 +8,7 @@ export function createStringifyProcessor(options = {}) {
8
8
  this.parser = function(root) {
9
9
  return JSON.parse(root);
10
10
  };
11
- }).use(mdcRemark).use(gfm).use(mdc, options?.plugins?.remarkMDC?.options || {}).use(stringify, {
11
+ }).use(mdcRemark).use(gfm).use(mdc, options?.plugins?.["remark-mdc"]?.options || options?.plugins?.remarkMDC?.options || {}).use(stringify, {
12
12
  bullet: "-",
13
13
  emphasis: "*",
14
14
  rule: "-",
@@ -101,7 +101,7 @@ const mdcRemarkNodeHandlers = {
101
101
  state.patch(node, result);
102
102
  return result;
103
103
  }
104
- const isInlineElement = (parent?.children || []).some((child) => child.type === "text") || ["p", "li", "strong", "em", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(parent?.tagName);
104
+ const isInlineElement = isForcedToBeInlineByItsParent(node, parent);
105
105
  if (isInlineElement) {
106
106
  return {
107
107
  type: mdastTextComponentType,
@@ -110,11 +110,29 @@ const mdcRemarkNodeHandlers = {
110
110
  children: state.all(node)
111
111
  };
112
112
  }
113
+ if (!["li", "p"].includes(parent?.tagName || "") && !node.children?.length) {
114
+ const attributes = Object.entries(node.properties || {});
115
+ if (attributes.length < 4 && !attributes.some(([key, value]) => String(value).includes("\n") || key.startsWith(":"))) {
116
+ return {
117
+ type: "paragraph",
118
+ children: [{
119
+ type: mdastTextComponentType,
120
+ name: node.tagName,
121
+ attributes: node.properties,
122
+ children: state.all(node)
123
+ }]
124
+ };
125
+ }
126
+ }
127
+ let children = state.all(node);
128
+ if (children.every((child) => [mdastTextComponentType, "text"].includes(child.type))) {
129
+ children = [{ type: "paragraph", children }];
130
+ }
113
131
  return {
114
132
  type: "containerComponent",
115
133
  name: node.tagName,
116
134
  attributes: node.properties,
117
- children: state.all(node)
135
+ children
118
136
  };
119
137
  }
120
138
  };
@@ -137,13 +155,24 @@ const mdcRemarkHandlers = {
137
155
  children: state.toFlow(state.all(node))
138
156
  };
139
157
  },
158
+ "li": (state, node) => {
159
+ const result = defaultHandlers.li(state, node);
160
+ if (result.children[0]?.type === "paragraph") {
161
+ const paragraph = result.children[0];
162
+ const lastChild = paragraph.children[paragraph.children.length - 1];
163
+ if (lastChild?.type === "text" && lastChild.value?.endsWith("\n")) {
164
+ lastChild.value = lastChild.value.trim();
165
+ }
166
+ }
167
+ return result;
168
+ },
140
169
  "ul": (state, node, parent) => {
141
170
  const result = defaultHandlers.ul(state, node);
142
- return parent?.tagName === "p" ? result : { type: "paragraph", children: [result] };
171
+ return ["p", "li"].includes(parent?.tagName || "") ? result : { type: "paragraph", children: [result] };
143
172
  },
144
173
  "ol": (state, node, parent) => {
145
174
  const result = defaultHandlers.ol(state, node);
146
- return parent?.tagName === "p" ? result : { type: "paragraph", children: [result] };
175
+ return ["p", "li"].includes(parent?.tagName || "") ? result : { type: "paragraph", children: [result] };
147
176
  },
148
177
  "code": (state, node) => {
149
178
  const attributes = { ...node.properties };
@@ -182,21 +211,19 @@ const mdcRemarkHandlers = {
182
211
  meta
183
212
  };
184
213
  },
185
- "button": (state, node) => {
186
- if (
187
- // @ts-expect-error: custom type
188
- node.children?.find((child) => child.type === mdcRemarkElementType) || node.children?.find((child) => child.type === "text" && child.value.includes("\n"))
189
- ) {
190
- return {
191
- type: "containerComponent",
192
- name: "button",
193
- children: state.all(node),
194
- attributes: node.properties
195
- };
214
+ "button": (state, node, parent) => {
215
+ if (isInlineNode(node, parent)) {
216
+ return createTextComponent("button")(state, node);
196
217
  }
197
- return createTextComponent("button")(state, node);
218
+ return {
219
+ type: "containerComponent",
220
+ name: "button",
221
+ children: state.all(node),
222
+ attributes: node.properties
223
+ };
198
224
  },
199
225
  "span": createTextComponent("span"),
226
+ "kbd": createTextComponent("kbd"),
200
227
  "binding": createTextComponent("binding"),
201
228
  "iframe": createTextComponent("iframe"),
202
229
  "video": createTextComponent("video"),
@@ -273,3 +300,24 @@ function createTextComponent(name) {
273
300
  return result;
274
301
  };
275
302
  }
303
+ function isForcedToBeInlineByItsParent(node, parent) {
304
+ if (["p", "li", "strong", "em", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(parent?.tagName || "")) {
305
+ return true;
306
+ }
307
+ if (parent?.children?.some((child) => child.type === "text")) {
308
+ return true;
309
+ }
310
+ return false;
311
+ }
312
+ function isInlineNode(node, parent) {
313
+ if (
314
+ // @ts-expect-error: custom type
315
+ node.children?.find((child) => child.type === mdcRemarkElementType) || node.children?.find((child) => child.type === "text" && child.value.includes("\n"))
316
+ ) {
317
+ return false;
318
+ }
319
+ if (!isForcedToBeInlineByItsParent(node, parent)) {
320
+ return false;
321
+ }
322
+ return true;
323
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.18.3",
3
+ "version": "0.19.0",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-content/mdc",
6
6
  "license": "MIT",
@@ -69,13 +69,13 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "@nuxt/kit": "^4.2.1",
72
- "@shikijs/core": "^3.15.0",
73
- "@shikijs/langs": "^3.15.0",
74
- "@shikijs/themes": "^3.15.0",
75
- "@shikijs/transformers": "^3.15.0",
72
+ "@shikijs/core": "^3.17.0",
73
+ "@shikijs/langs": "^3.17.0",
74
+ "@shikijs/themes": "^3.17.0",
75
+ "@shikijs/transformers": "^3.17.0",
76
76
  "@types/hast": "^3.0.4",
77
77
  "@types/mdast": "^4.0.4",
78
- "@vue/compiler-core": "^3.5.24",
78
+ "@vue/compiler-core": "^3.5.25",
79
79
  "consola": "^3.4.2",
80
80
  "debug": "^4.4.3",
81
81
  "defu": "^6.1.4",
@@ -85,7 +85,7 @@
85
85
  "hast-util-format": "^1.1.0",
86
86
  "hast-util-to-mdast": "^10.1.2",
87
87
  "hast-util-to-string": "^3.0.1",
88
- "mdast-util-to-hast": "^13.2.0",
88
+ "mdast-util-to-hast": "^13.2.1",
89
89
  "micromark-util-sanitize-uri": "^2.0.1",
90
90
  "parse5": "^8.0.0",
91
91
  "pathe": "^2.0.3",
@@ -99,12 +99,12 @@
99
99
  "rehype-sort-attributes": "^5.0.1",
100
100
  "remark-emoji": "^5.0.2",
101
101
  "remark-gfm": "^4.0.1",
102
- "remark-mdc": "^3.8.1",
102
+ "remark-mdc": "^3.9.0",
103
103
  "remark-parse": "^11.0.0",
104
104
  "remark-rehype": "^11.1.2",
105
105
  "remark-stringify": "^11.0.0",
106
106
  "scule": "^1.3.0",
107
- "shiki": "^3.15.0",
107
+ "shiki": "^3.17.0",
108
108
  "ufo": "^1.6.1",
109
109
  "unified": "^11.0.5",
110
110
  "unist-builder": "^4.0.0",
@@ -113,12 +113,12 @@
113
113
  "vfile": "^6.0.3"
114
114
  },
115
115
  "devDependencies": {
116
- "@nuxt/devtools": "^3.1.0",
117
- "@nuxt/eslint-config": "^1.10.0",
116
+ "@nuxt/devtools": "^3.1.1",
117
+ "@nuxt/eslint-config": "^1.11.0",
118
118
  "@nuxt/module-builder": "^1.0.2",
119
119
  "@nuxt/schema": "^4.2.1",
120
120
  "@nuxt/test-utils": "^3.20.1",
121
- "@nuxt/ui": "^4.1.0",
121
+ "@nuxt/ui": "^4.2.1",
122
122
  "@nuxtjs/mdc": "link:.",
123
123
  "@types/node": "^24.10.1",
124
124
  "eslint": "^9.39.1",
@@ -126,13 +126,13 @@
126
126
  "rehype": "^13.0.2",
127
127
  "release-it": "^19.0.6",
128
128
  "typescript": "5.9.3",
129
- "vitest": "^4.0.8",
130
- "vue-tsc": "^3.1.3"
129
+ "vitest": "^4.0.14",
130
+ "vue-tsc": "^3.1.5"
131
131
  },
132
132
  "resolutions": {
133
133
  "@nuxtjs/mdc": "workspace:*"
134
134
  },
135
- "packageManager": "pnpm@10.22.0",
135
+ "packageManager": "pnpm@10.24.0",
136
136
  "release-it": {
137
137
  "git": {
138
138
  "commitMessage": "chore(release): release v${version}"