Have you read the Contributing Guidelines on issues?
Prerequisites
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 install
yarn 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
Self-service
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."
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clearoryarn clearcommand.rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages.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:
Reproducible demo
https://github.com/SethFalco/metadata-sandbox
Steps to reproduce
yarn installyarn run buildbuild/docs/index.htmlExpected behavior
They should be:
Actual behavior
While the page itself renders correctly, the
<metadata>nodes don't match what one would expect:Your environment
Self-service
Proposed Test Cases
packages/docusaurus-utils/src/__tests__/markdownUtils.test.tsResults (truncated):