-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Make most features work in CommonMark mode: head, live code blocks, tabs... #9092
Comments
Is my understanding correct that CommonMark mode does not allow providing custom components at all? If so, do we need to walk the React element tree created by mdx-loader in client code so we can inject our React components? It seems rather imperative for us to make |
It does not allow the usage of JSX when parsing the input, but it still compiles to React components, and you can process the AST so that it outputs what you want, reading components from the provider. I recently added a few useful options to the MDX playground to make this easier to understand. Note: when using the lowercase What I mean is technically nothing prevents of from offering a feature parity for most of these features, so if we can, why not! |
Hmmm my mistake, with CommonMark mode even lowercase elements seem to be able to read from the provider: function _createMdxContent(props) {
const _components = Object.assign({
details: "details",
summary: "summary",
p: "p"
}, props.components);
return _jsxs(_components.details, {
children: ["\n ", _jsx(_components.summary, {
children: "MD Summary"
}), "\n", _jsx(_components.p, {
children: "Our custom Details/Summary also works in CommonMark mode"
}), "\n"]
});
} which is not the case for the mdx mode: function _createMdxContent(props) {
const _components = Object.assign({
p: "p"
}, props.components);
return _jsxs("details", {
children: [_jsx("summary", {
children: "MD Summary"
}), _jsx(_components.p, {
children: "Our custom Details/Summary also works in CommonMark mode"
})]
});
} I was able to make the details work in CommonMark by simply adding a lowercase |
Some elements like SEO Unless we are able to fix all these critical elements fast, I think we can consider our CommonMark mode as "experimental" and eventually stabilize it in a further minor release. For v3 I think it's safer to keep the MDX parser by default even for |
In my case, I make a remark plugin to using directive Maybe all the features can be landing as directive. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
- these files used {string}, which is now evaluated as an expression in mdx (https://mdxjs.com/docs/what-is-mdx/#expressions) -> setup docusaurus to only use mdx on .mdx files, because api is generated as normal .md The docusaurus CommonMark feature is experimental: https://docusaurus.io/docs/markdown-features#mdx-vs-commonmark With following limitations:facebook/docusaurus#9092 For reference, failing files were: - "/api/Dalamud.Interface.Utility/Structs/ImVectorWrapper`T`" - "/api/Dalamud.Utility.Timing/Classes/Timings" - "/api/Dalamud.Utility/Classes/DisposeSafety.ScopedFinalizer" - "/api/FFXIVClientStructs.Interop/" - "/api/FFXIVClientStructs.Interop/Structs/SpanExtensions.SpanPointerEnumerator`T`"
- these files used {string}, which is now evaluated as an expression in mdx (https://mdxjs.com/docs/what-is-mdx/#expressions) -> setup docusaurus to only use mdx on .mdx files, because api is generated as normal .md The docusaurus CommonMark feature is experimental: https://docusaurus.io/docs/markdown-features#mdx-vs-commonmark With following limitations:facebook/docusaurus#9092 For reference, failing files were: - "/api/Dalamud.Interface.Utility/Structs/ImVectorWrapper`T`" - "/api/Dalamud.Utility.Timing/Classes/Timings" - "/api/Dalamud.Utility/Classes/DisposeSafety.ScopedFinalizer" - "/api/FFXIVClientStructs.Interop/" - "/api/FFXIVClientStructs.Interop/Structs/SpanExtensions.SpanPointerEnumerator`T`"
* Bump docusaurus + update all dependencies: - docusaurus 3-alpha -> 3.4 - everything to latest, except: - eslint to v8, e.g. @typescript-eslint/parser doesn't support v9 yet - typescript ~5.4, because eslint v8 expects a version <5.5.0 - node >= 18 due to various dependencies dropping 16 Change prism-react-renderer import as necessary * Add @docusaurus/types as dev dependency - used in docusaurus.config.js already * Migration to husky v9 * Fix broken file (due to mdx3 being less lenient) * Update all used github actions: - due to warning from github to versions using node 20 * Change build pipeline to .NET 8 * Update pnpm to latest (9.4.0): Note: the new setup action now fails if a different version is used in package.json vs workflows config * workaround API build failing on 5 files: - these files used {string}, which is now evaluated as an expression in mdx (https://mdxjs.com/docs/what-is-mdx/#expressions) -> setup docusaurus to only use mdx on .mdx files, because api is generated as normal .md The docusaurus CommonMark feature is experimental: https://docusaurus.io/docs/markdown-features#mdx-vs-commonmark With following limitations:facebook/docusaurus#9092 For reference, failing files were: - "/api/Dalamud.Interface.Utility/Structs/ImVectorWrapper`T`" - "/api/Dalamud.Utility.Timing/Classes/Timings" - "/api/Dalamud.Utility/Classes/DisposeSafety.ScopedFinalizer" - "/api/FFXIVClientStructs.Interop/" - "/api/FFXIVClientStructs.Interop/Structs/SpanExtensions.SpanPointerEnumerator`T`" * Add 'bash' as additionalLanguage for prisms syntax highlighting: shell code wasn't highlighted, e.g. building/index.md * Update README: - Docusaurus 3 - always has been - with v3 pnpm build works locally when using --dev * Replace caution with warning due to deprecation in v3 * Change docusaurus.config.js to ES Module as recommended in the Migration Guide
Motivation
Related to the CommonMark support issue: #3018
Some custom elements we created do not work when using the CommonMark parser mode, that you can turn on using:
frontMatter.mdx.format: 'md'
config.markdown.format: 'detect'
+ using the.md
extensionI think it would be convenient for users to have features working fine in both modes in a consistent way. I believe it is possible, but may require some adaptations.
Here are some components that do not currently work:
SEO
This should work in CommonMark too, but currently does not:
Summary/details
Renders as:
Instead of:
Live code editor
Renders as:
Instead of:
Tabs
Renders as: N/A because we don't have any syntax that does not require using MDX/ESM imports.
Instead of:
Possible solution? IMHO this syntax should be allowed without imports:
Structured data
As part of #9669 we are adding a
@theme/StructuredData
helper component:We should figure out how to define structured data in CommonMark mode
Self-service
The text was updated successfully, but these errors were encountered: