Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit dcdb3bd

Browse files
committed
feat(mdx-loader): add classes to block-start
1 parent b1bd45f commit dcdb3bd

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

packages/mdx-loader/__tests__/__snapshots__/index.js.snap

+14-4
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ export const slides = [props => <>
191191
<div>
192192
<p>{\`out\`}</p>
193193
<div className=\\"foo\\">
194-
<p>{\`in
195-
in\`}</p>
194+
<p>{\`in\`}</p>
195+
<div className=\\"foo bar baz\\">
196+
<p>{\`core\`}</p>
197+
</div>
198+
<p>{\`in\`}</p>
196199
</div>
197200
<p>{\`out\`}</p>
198201
</div>
@@ -217,8 +220,15 @@ export default function MDXContent({
217220
{
218221
/* block-start: foo */
219222
}
220-
<p>{\`in
221-
in\`}</p>
223+
<p>{\`in\`}</p>
224+
{
225+
/* block-start:foo,bar, baz */
226+
}
227+
<p>{\`core\`}</p>
228+
{
229+
/* block-end */
230+
}
231+
<p>{\`in\`}</p>
222232
{
223233
/* block-end */
224234
}

packages/mdx-loader/__tests__/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ second
159159
out
160160
<!-- block-start: foo -->
161161
in
162+
<!-- block-start:foo,bar, baz -->
163+
core
164+
<!-- block-end -->
162165
in
163166
<!-- block-end -->
164167
out

packages/mdx-loader/src/mdxPlugin.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ function mdxPlugin() {
160160

161161
for (const pos of matches) {
162162
const [, className] = pos;
163-
const div = className ? `<div className="${className.trim()}">` : '<div>';
163+
const formattedClassName = commentParser(`0:${className}`).valueStr.replace(/,/g, ' ');
164+
const div = className ? `<div className="${formattedClassName}">` : '<div>';
164165

165166
mdxJSX = mdxJSX.replace(/{\s.+\/\* block-start:?(.*?) \*\/\s.+}/m, div);
166167
}

0 commit comments

Comments
 (0)