-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
HTML comments hidden in texts but displayed in DocCard #10589
Comments
I want to work on this @tomasdahlqvist , can you please assign this to me :-) |
Can you assign this to me |
Note HTML comments are not valid MDX syntax, and Docusaurus v3 interprets We do add back support for HTML comments as a workaround to ease the adoption of Docusaurus v3, but it's preferable to use either That being said, we add back support for HTML comments through a lib: https://github.com/leebyron/remark-comment There was a bug in multiline comments that I tried to fix in this PR: leebyron/remark-comment#3 I'm not an expert in extending Markdown syntax and it's probable that my attempt has unsupported edge cases. |
Oh damn, I misunderstood the problem. Indeed the card will display the comment, but not only. This is because the card description has to be a pure string and we do a best effort to extract and serialize that string to display it in that card. Our docs tell you the behavior: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs
This is not only used in the card, but also on SEO description metadata and eventually other places. Unfortunately we won't really be able to solve this. The description has to be a pure string. We provide a default but if the default is not good enough to you, you should rather provide an explicit |
I found it strange that one line comments work but not multiline. Also in for example #9691 the and /* */ syntax are both viable. |
This is because the logic that creates the excerpt/description is not a real markdown parser but a best-effort regexp. Using a real parser for that would have significant overhead, and it's preferable to not penalize all users in terms of performance, and ask them to provide an explicit description. |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Mutli-line HTML comments are not removed from previews. The preview then contains the first line of the comment instead of the actual content.
Reproducible demo
https://stackblitz.com/github/facebook/docusaurus/tree/main/examples/classic-typescript?file=docs%2Ftutorial-basics%2Fcreate-a-document.md
Steps to reproduce
sidebar_position: 2
Create a Document
Documents are ...
2. View the card layout from the page "Tutorial - Basics"
3. The description in the card is "<!-- black"
Expected behavior
The html comment should be ignored even if it is multi-line.
Actual behavior
Your environment
Self-service
The text was updated successfully, but these errors were encountered: