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

Handle .mdx files #604

Open
nafg opened this issue Jan 12, 2022 · 5 comments
Open

Handle .mdx files #604

nafg opened this issue Jan 12, 2022 · 5 comments

Comments

@nafg
Copy link

nafg commented Jan 12, 2022

mdoc seems to be designed to work with Docusaurus, which uses MDX. Tools understand MDX better when the file extension is .mdx. Mdoc should process .mdx files the same way as .md files.

@kpodsiad
Copy link
Member

kpodsiad commented Feb 9, 2022

@olafurpg I wonder if adding mdx to the

markdownExtensions: List[String] = List("md", "html"),

will be enough? As far I can tell it should allow to process mdx files but I've never seen mdoc codebase before and I'm not sure.

@tgodzik
Copy link
Contributor

tgodzik commented Feb 10, 2022

I think that should work, did you manage to test it out @kpodsiad ?

@kpodsiad
Copy link
Member

It's not enough, .mdx file is just copied without resolving fenced code block.

@olafurpg
Copy link
Member

Have you tried the flag —markdown-extensions=mdx? Everything in that settings file can be configured via the command line or sbt plugin

@baldram
Copy link

baldram commented Feb 18, 2024

Everything in that settings file can be configured via the command line or sbt plugin

I tried and it worked, though it feels more like a workaround than a proper configuration.

I'm not sure how to configure these things from the SBT plugin level, since markdownExtensions is in the mdoc.internal.cli package. But I managed to hack it like this:

mdocExtraArguments ++= Seq("--markdown-extensions", "mdx", "--markdown-extensions", "md", "--markdown-extensions", "html")

(I had to repeat markdown-extensions multiple times because I couldn't set it once for all as md,mdx,html).

It seems to me that mdx should just be permanently added; it shouldn't be an option, because from Docusaurus version 2 (and we're now on version 3), it has built-in support for MDX, and that's a standard thing.

Putting aside the fact that Docusaurus has moved ahead of Mdoc (which by default supports Docusaurus v1 only), it's worth considering supporting the latest version. Even from version 2, it offers several key benefits, like more customization options and better UX. They are essential for modern-looking, clear and easy-to-read documentation.

And generally, not many changes are needed. I'm currently using Mdoc with Docusaurus 3 (but without using the DocusaurusPlugin to avoid hacks and workarounds).

To sum up, I tested it and everything works 😄 Just takes a bit of stubbornness and perseverance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants