Repository navigation
Closed
leebyron/remark-comment
#3Labels
bugAn error in the Docusaurus core causing instability or issues with its executiondomain: markdownRelated to Markdown parsing or syntax
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
The following HTML comments are fine:
<!-- Single line comment -->
<!-- Multi
line comment
-->
However, a multi-line comment which does not start on the opening line leads to an error:
<!--
Github Flavoured Markdown does not support tables without headers.
We must use an HTML table here.
Please note that Spacing in this table is important.
Markdown must have empty newlines between it and HTML markup.
-->
And the error:
Error: MDX compilation failed for file "/Users/nicols/git/moodlehq/devdocs/general/releases/2.3.md"
Cause: chunks[startIndex].slice is not a function
Details:
{}
Reproducible demo
No response
Steps to reproduce
Create an mdx file with:
<!--
Github Flavoured Markdown does not support tables without headers.
We must use an HTML table here.
Please note that Spacing in this table is important.
Markdown must have empty newlines between it and HTML markup.
-->
Expected behavior
HTML comment not shown
Actual behavior
An error in the yarn console:
Error: MDX compilation failed for file "/Users/nicols/git/moodlehq/devdocs/general/releases/2.3.md"
Cause: chunks[startIndex].slice is not a function
Details:
{}
Your environment
- Public source code: https://github.com/moodle/devdocs
- Public site URL: https://moodledev.io
- Docusaurus version used: 3.0.0-alpha.0
- Environment name and version Netlify
- Operating system and version Netlify
3.0 branch is at andrewnicols/devdocs@docusaurus3
Self-service
- I'd be willing to fix this bug myself.
Metadata
Metadata
Assignees
Labels
bugAn error in the Docusaurus core causing instability or issues with its executiondomain: markdownRelated to Markdown parsing or syntax
Activity
slorber commentedon Jun 22, 2023
Thanks for reporting.
Unfortunately there's no stacktrace logged in this case in the console output, but only on the webpack dev server:
I can reproduce on our own website, but can't reproduce on the MDX playground surprisingly 🤷♂️ Will need to investigate all this a bit more, but HTML comments like this are definitively supposed to work with the CommonMark format.
First of all, for this file, do you want to use keep using the mdx format (as in v2?) or do you want to switch to commonmark? From now on MDX does not support HTML comments anymore (although we provide a compat mode), so if you want to keep using the same parsing logic you eventually have to use MDX comments instead. I just want to make sure that you understand that using the
.mdfile extension currently switches you to a commonmark mode, as explained in the PR: #8288. I'm going to change that soon and use mdx as a default even for .md files to make it easier to upgrade without renaming file extensions, but for the first alpha the switch is based on the extension, see also #3018 (comment).andrewnicols commentedon Jun 22, 2023
Thanks @slorber,
I suspect that we'll initially stick with .md and commonmark, but I suspect we'll migrate to mdx as default for new content and then I'll have the unenviable task of updating existing content too (currently 860 pages).
I'm still trying to get my head around the various changes we need to make to get this to work. So far this is the only breaking change apart from the expected rewrite of our mdx remark plugins.
slorber commentedon Jun 22, 2023
Hmmm apparently this is related to a bug in remark-comment, that I already reported 🤪
leebyron/remark-comment#2
slorber commentedon Jun 22, 2023
Already sent a PR with a fix: leebyron/remark-comment#3
We'll see when it will be merged/published.
In the meantime you can use this escape hatch:
To make sure we are able to support multi-line comments, I added some to our own site as part of #9093