sommark 3.3.2 → 3.3.3
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/core/transpiler.js
CHANGED
|
@@ -56,11 +56,12 @@ async function generateOutput(ast, i, format, mapper_file) {
|
|
|
56
56
|
// ========================================================================== //
|
|
57
57
|
// Always use placeholders for blocks to support wrapping //
|
|
58
58
|
// ========================================================================== //
|
|
59
|
-
const
|
|
59
|
+
const isParentBlock = format === mdxFormat && node.body.length > 1;
|
|
60
|
+
const placeholder = isParentBlock ? `\n${BODY_PLACEHOLDER}\n` : BODY_PLACEHOLDER;
|
|
60
61
|
const textContent = getNodeText(node);
|
|
61
62
|
|
|
62
63
|
result += target.render.call(mapper_file, { args: node.args, content: placeholder, textContent, ast: node });
|
|
63
|
-
if (
|
|
64
|
+
if (isParentBlock) result = "\n" + result + "\n";
|
|
64
65
|
|
|
65
66
|
// ========================================================================== //
|
|
66
67
|
// Process body nodes recursively //
|
|
@@ -112,7 +113,12 @@ async function generateOutput(ast, i, format, mapper_file) {
|
|
|
112
113
|
|
|
113
114
|
case BLOCK:
|
|
114
115
|
const blockOutput = await generateOutput(body_node, i, format, mapper_file);
|
|
115
|
-
|
|
116
|
+
const blockIsParent = format === mdxFormat && body_node.body.length > 1;
|
|
117
|
+
if (format === mdxFormat && !blockIsParent) {
|
|
118
|
+
context += blockOutput;
|
|
119
|
+
} else {
|
|
120
|
+
context = context.trim() ? context.trimEnd() + "\n" + blockOutput : context + blockOutput;
|
|
121
|
+
}
|
|
116
122
|
break;
|
|
117
123
|
}
|
|
118
124
|
}
|
|
@@ -138,7 +144,8 @@ async function generateOutput(ast, i, format, mapper_file) {
|
|
|
138
144
|
`<$yellow:Identifier$> <$blue:'${node.id}'$> <$yellow: is not found in mapping outputs$>{line}`
|
|
139
145
|
]);
|
|
140
146
|
}
|
|
141
|
-
|
|
147
|
+
const newline = (format === mdxFormat && node.body.length <= 1) ? "" : "\n";
|
|
148
|
+
return result.trimEnd() + newline;
|
|
142
149
|
}
|
|
143
150
|
|
|
144
151
|
// ========================================================================== //
|
package/mappers/languages/mdx.js
CHANGED
|
@@ -90,7 +90,7 @@ const { tag } = MDX;
|
|
|
90
90
|
MDX.inherit(MARKDOWN);
|
|
91
91
|
|
|
92
92
|
// Block for raw MDX content (ESM, etc.)
|
|
93
|
-
MDX.register("mdx", ({ content }) => content, { escape: false, type: "Block" });
|
|
93
|
+
MDX.register("mdx", ({ content }) => content, { escape: false, type: ["AtBlock", "Block"] });
|
|
94
94
|
|
|
95
95
|
// Re-register HTML tags to use jsxProps
|
|
96
96
|
HTML_TAGS.forEach(tagName => {
|
package/package.json
CHANGED