Skip to content
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

format: md front matter doesn't work #10628

Open
4 of 7 tasks
doraeric opened this issue Oct 30, 2024 · 1 comment
Open
4 of 7 tasks

format: md front matter doesn't work #10628

doraeric opened this issue Oct 30, 2024 · 1 comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@doraeric
Copy link

doraeric commented Oct 30, 2024

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and 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 docs say that adding format: md front matter makes the doc to be CommonMark format, but it doesn't work.
After looking into the code, it should be

---
mdx:
  format: md
---

It reads the mdx in front matter first

const mdxFrontMatter = validateMDXFrontMatter(frontMatter.mdx);
const processor = await getProcessor({
filePath,
options,
mdxFrontMatter,
});

export async function getProcessor({
filePath,
mdxFrontMatter,
options,
}: {
filePath: string;
mdxFrontMatter: MDXFrontMatter;
options: Options;
}): Promise<SimpleProcessor> {
const processors =
options.processors ?? (await createProcessorsCacheEntry({options}));
const format = getFormat({
filePath,
frontMatterFormat: mdxFrontMatter.format,
markdownConfigFormat: options.markdownConfig.format,
});
return format === 'md' ? processors.mdProcessor : processors.mdxProcessor;
}

But the docs say it's format in front matter.


It is possible to **opt-in for CommonMark** using the [`siteConfig.markdown.format`](../../api/docusaurus.config.js.mdx#markdown) setting or the `format: md` front matter.

Should it be fixed in the code or in the docs?

Reproducible demo

No response

Steps to reproduce

  1. add format: md front matter in .mdx file
  2. nothing happened

Expected behavior

Doc changes to CommonMark syntax.

Actual behavior

Doc stay with JSX syntax

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used: v3
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.
@doraeric doraeric added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Oct 30, 2024
@slorber
Copy link
Collaborator

slorber commented Oct 30, 2024

Damn, yes you are right 😅

Should it be fixed in the code or in the docs?

Hmmm, I don't know. I'd like to have format: instead of mdx.format but at the same time it's likely that we add extra options under the mdx namespace. I think we should just fix the docs.

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

2 participants