-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Treat .mdx as .md file for now #4416
Conversation
MDX (.mdx) is an superset on top of CommonMark (Markdown) that supports JSX and JavaScript's imports/exports: - MDX: https://mdxjs.com/ - CommonMark: https://commonmark.org/ - JSX: https://facebook.github.io/jsx/ - export: https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export - import: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import I don't know what supporting the full syntax of MDX would look like for GitHub, but this will at least improve it somewhat
Note: Right now, many users are making their This extension could be moved to another language definition later on, but for now it will cause people to use the correct file extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is missing a sample .mdx
file. Could you add one under samples/Markdown/
? This one will do (decent-size example, MIT-licensed).
Other than that, everything looks great. 👍
@Alhadis Done! |
LGTM! 👍 /cc @lildude |
Looks like rendering of |
If users are deliberately using |
@Alhadis Except they might be careful and only use |
I was planning on coming back to this when I have more time to improve the situation even more. There are syntax definitions for MDX files that Linguist could use, but how GitHub renders them is a whole other question. I'd need to figure out how to get GitHub to render a separate format as Markdown and how to make the imports/exports/jsx render as code blocks. |
Rendering is handled by Bear in mind: I don't believe the I'm afraid you're unlikely to have any luck, given how much of a trainwreck the NPM ecosystem is when it comes to dependencies and security. |
Referencing #6339, which adds a proper syntax highlighting grammar :) |
MDX is a literate programming language that combines markdown with several JavaScript language features, such as JSX, expressions, and ESM. * markdown: <https://commonmark.org/> * JavaScript: <https://tc39.es/ecma262/> * JSX: <https://facebook.github.io/jsx/> Previously, there was some temporary duct-tape in place, to map `.mdx` extensions to markdown: github-linguistGH-4416. This improved the situation from nothing to something, but has issues, because the syntax that MDX brings wasn’t highlighted. With this grammar, those can be properly highlighted. Related-to: github-linguistGH-4416.
* Add MDX language MDX is a literate programming language that combines markdown with several JavaScript language features, such as JSX, expressions, and ESM. * markdown: <https://commonmark.org/> * JavaScript: <https://tc39.es/ecma262/> * JSX: <https://facebook.github.io/jsx/> Previously, there was some temporary duct-tape in place, to map `.mdx` extensions to markdown: GH-4416. This improved the situation from nothing to something, but has issues, because the syntax that MDX brings wasn’t highlighted. With this grammar, those can be properly highlighted. Related-to: GH-4416. * Add id --------- Co-authored-by: Colin Seymour <[email protected]>
Description
MDX (
.mdx
) is an superset on top of CommonMark (Markdown) that supports JSX and JavaScript's imports/exports:export
: https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/exportimport
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/importI don't know what supporting the full syntax of MDX would look like for GitHub, but this will at least improve it somewhat
Syntax Example
Checklist: