@nuxtjs/mdc 0.18.4 → 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.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
3
  "configKey": "mdc",
4
- "version": "0.18.4",
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: {
@@ -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,6 +110,20 @@ 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
+ }
113
127
  let children = state.all(node);
114
128
  if (children.every((child) => [mdastTextComponentType, "text"].includes(child.type))) {
115
129
  children = [{ type: "paragraph", children }];
@@ -141,13 +155,24 @@ const mdcRemarkHandlers = {
141
155
  children: state.toFlow(state.all(node))
142
156
  };
143
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
+ },
144
169
  "ul": (state, node, parent) => {
145
170
  const result = defaultHandlers.ul(state, node);
146
- return parent?.tagName === "p" ? result : { type: "paragraph", children: [result] };
171
+ return ["p", "li"].includes(parent?.tagName || "") ? result : { type: "paragraph", children: [result] };
147
172
  },
148
173
  "ol": (state, node, parent) => {
149
174
  const result = defaultHandlers.ol(state, node);
150
- return parent?.tagName === "p" ? result : { type: "paragraph", children: [result] };
175
+ return ["p", "li"].includes(parent?.tagName || "") ? result : { type: "paragraph", children: [result] };
151
176
  },
152
177
  "code": (state, node) => {
153
178
  const attributes = { ...node.properties };
@@ -186,19 +211,16 @@ const mdcRemarkHandlers = {
186
211
  meta
187
212
  };
188
213
  },
189
- "button": (state, node) => {
190
- if (
191
- // @ts-expect-error: custom type
192
- node.children?.find((child) => child.type === mdcRemarkElementType) || node.children?.find((child) => child.type === "text" && child.value.includes("\n"))
193
- ) {
194
- return {
195
- type: "containerComponent",
196
- name: "button",
197
- children: state.all(node),
198
- attributes: node.properties
199
- };
214
+ "button": (state, node, parent) => {
215
+ if (isInlineNode(node, parent)) {
216
+ return createTextComponent("button")(state, node);
200
217
  }
201
- return createTextComponent("button")(state, node);
218
+ return {
219
+ type: "containerComponent",
220
+ name: "button",
221
+ children: state.all(node),
222
+ attributes: node.properties
223
+ };
202
224
  },
203
225
  "span": createTextComponent("span"),
204
226
  "kbd": createTextComponent("kbd"),
@@ -278,3 +300,24 @@ function createTextComponent(name) {
278
300
  return result;
279
301
  };
280
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.4",
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.10",
130
- "vue-tsc": "^3.1.4"
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}"