-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Open
Labels
bugAn error in the Docusaurus core causing instability or issues with its executionAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainersThis issue has not been triaged by maintainers
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
Docusaurus doesn't correctly generate the metadata fields on pages when the first sentence of a page includes inline-code syntax with something that looks like an XML taga inside.
Example:
Removes the
<metadata>element from the document.
Removes the [`<metadata>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/metadata) element from the document.Reproducible demo
https://github.com/SethFalco/metadata-sandbox
Steps to reproduce
- Clone the repo
yarn installyarn run build- Inspect
build/docs/index.html
Expected behavior
They should be:
<meta data-rh="true" name="description" content="Removes the <metadata> element from the document.">
<meta data-rh="true" property="og:description" content="Removes the <metadata> element from the document.">
<p>Removes the <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/metadata" target="_blank" rel="noopener noreferrer" class=""><code><metadata></code></a> element from the document.</p>Actual behavior
While the page itself renders correctly, the <metadata> nodes don't match what one would expect:
<meta data-rh="true" name="description" content="Removes the `` element from the document.">
<meta data-rh="true" property="og:description" content="Removes the `` element from the document.">
<p>Removes the <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/metadata" target="_blank" rel="noopener noreferrer" class=""><code><metadata></code></a> element from the document.</p>Your environment
- Public source code: https://github.com/svg/svgo.dev
- Public site URL: https://svgo.dev
- Docusaurus version used: v3.9.2
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js v24.14.0
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): Debian Trixie
Self-service
- I'd be willing to fix this bug myself.
Proposed Test Cases
packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts
it('creates excerpt with XML tag inside inline code', () => {
expect(
createExcerpt(dedent`
# Markdown Regular Title
This paragraph includes a link to the \`<metadata>\` documentation.
`),
).toBe('This paragraph includes a link to the <metadata> documentation.');
});
it('creates excerpt with XML tag inside inline code with hyperlink', () => {
expect(
createExcerpt(dedent`
# Markdown Regular Title
This paragraph includes a link to the [\`<metadata>\`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/metadata) documentation.
`),
).toBe('This paragraph includes a link to the <metadata> documentation.');
});Results (truncated):
FAIL packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts
● createExcerpt › creates excerpt with XML tag inside inline code
Expected: "This paragraph includes a link to the <metadata> documentation."
Received: "This paragraph includes a link to the `` documentation."
● createExcerpt › creates excerpt with XML tag inside inline code with hyperlink
Expected: "This paragraph includes a link to the <metadata> documentation."
Received: "This paragraph includes a link to the `` documentation."
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugAn error in the Docusaurus core causing instability or issues with its executionAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainersThis issue has not been triaged by maintainers