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

Add mdx language #3096

Merged
merged 18 commits into from
Jul 7, 2023
Merged

Add mdx language #3096

merged 18 commits into from
Jul 7, 2023

Conversation

remcohaszing
Copy link
Contributor

@remcohaszing remcohaszing commented May 5, 2022

This is an initial attempt to add MDX language support to Monaco editor. MDX is a language which extends markdown by allowing the use of JSX and ecmascript imports and exports.

I am having some issues implementing this though. Some help would be greatly appreciated.

I’ve been using the following code for testing:

import { MyComponent } from './MyComponent'

This is **bold {1 + 2} text**

# Hello MDX

{'foo' + 1 + 2}

{/* this is a comment */}

<MyComponent asd="text-green-700" foo='bar' asd={1 + 4}>

  This is **also** markdown.

</MyComponent>
  • The JSX component highlighting is broken due to the props. If they are removed, highlighting is fixed. Fixed
  • Is is possible to highlight the JavaScript expression inside the bold markdown text? Yep, done
  • If I add the following JavaScript expression {1 + {}}, an error is thrown: Error: mdx: cannot pop embedded language if not inside one No longer throws, but the closing bracket does exit the javascript embedded language.

I think it’s very much usable in the current state.

image

image

@remcohaszing
Copy link
Contributor Author

remcohaszing commented May 12, 2022

This includes syntax highlighting for JSX. It may be useful to backport these to javascript and typescript, or create new languages javascriptreact and typescriptreact to match VSCode behaviour. (#264)

This also includes some more advanced markdown features currently not available in the markdown language, such as frontmatter of nesting inline content (e.g. emphasis inside bold inside a header). It may be useful to port these to markdown too.

remcohaszing added a commit to remcohaszing/emmet-monaco-es that referenced this pull request May 13, 2022
The MDX support is based on microsoft/monaco-editor#3096, which hasn’t
been merged yet.
@hediet hediet added this to the July 2022 milestone Jul 21, 2022
CONTRIBUTING.md Outdated Show resolved Hide resolved
Copy link
Member

@hediet hediet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! I left a comment. Especially for third party contributions, tests are crucial!

src/basic-languages/mdx/mdx.test.ts Outdated Show resolved Hide resolved
hediet
hediet previously approved these changes Mar 31, 2023
@hediet hediet modified the milestones: July 2022, March 2023 Mar 31, 2023
bpasero
bpasero previously approved these changes Mar 31, 2023
@remcohaszing remcohaszing dismissed stale reviews from bpasero and hediet via 1322e33 April 7, 2023 13:56
@remcohaszing
Copy link
Contributor Author

Sorry it took so long, but I added some tests!

@grandsmarquis
Copy link

Hello, is there any update?

@hediet hediet modified the milestones: March 2023, July 2023 Jul 7, 2023
@hediet hediet removed the info-needed Issue requires more information from poster label Jul 7, 2023
@hediet hediet enabled auto-merge July 7, 2023 14:45
@hediet hediet merged commit e6c4ace into microsoft:main Jul 7, 2023
@remcohaszing remcohaszing deleted the mdx branch July 7, 2023 15:06
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants