-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not support multi-line HTML comments? #2
Comments
Thanks for the report! Have you been able to do any debugging by chance? I noticed that this package didn't show up in that stack trace so any extra information you have about this particular case would be quite helpful for a fast resolution. Thanks for spotting the opportunity for tests for this case. That seems like the right thing to add once this is figured out. |
Did some tests, and it indeed looks like a bug in this plugin. const { createProcessor: createMdxProcessor } = await import("@mdx-js/mdx");
const { default: comment } = await import("remark-comment"); The first 2 works fine 👍 createMdxProcessor({
rehypePlugins: [],
remarkPlugins: [comment],
format: "md"
})
.process({
value: `
<!-- test md
some html comment.
-->`
})
.then(res => console.log(res.toString()));
createMdxProcessor({
rehypePlugins: [],
remarkPlugins: [comment],
format: "mdx"
})
.process({
value: `
<!-- test mdx
some html comment.
-->`
})
.then(res => console.log(res.toString())); The last 2 fails with error message above. createMdxProcessor({
rehypePlugins: [],
remarkPlugins: [comment],
format: "md"
})
.process({
value: `
test md
<!--
some html comment.
-->`
})
.then(res => console.log(res.toString()));
createMdxProcessor({
rehypePlugins: [],
remarkPlugins: [comment],
format: "mdx"
})
.process({
value: `
test mdx
<!--
some html comment.
-->`
})
.then(res => console.log(res.toString())); More info about variables in the method that throws: {
chunks: [
-4,
'test md',
-4,
'<!--',
-4,
'some html comment.',
-4,
'-->',
null
],
startIndex: 4,
endIndex: 4,
startBufferIndex: -1,
endBufferIndex: -1
}
{
chunks: [
-4,
'test mdx',
-4,
'<!--',
-4,
'some html comment.',
-4,
'-->',
null
],
startIndex: 4,
endIndex: 4,
startBufferIndex: -1,
endBufferIndex: -1
} Note that using this comment with an extra useless space after the opening makes it work: <!--
some html comment.
--> This workaround makes all 4 test cases pass: fileContent = fileContent.replaceAll('<!--\n', '<!-- \n'); |
Sent a draft PR with a failing test case: #3 Not super familiar with the code in this repo so not sure I'll be able to fix it easily 😅 any idea what could be wrong in the current implementation? |
When using multi-line HTML comments, this plugin seems to lead to an error
Unit tests do not seem to cover multi-line comments.
The text was updated successfully, but these errors were encountered: