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

Select Specific Languages for Code Highlighting #644

Open
martinomburajr opened this issue May 23, 2024 · 3 comments
Open

Select Specific Languages for Code Highlighting #644

martinomburajr opened this issue May 23, 2024 · 3 comments

Comments

@martinomburajr
Copy link

I wanted to know if it were possible to select specific languages to be included in the bundle for code highlighting.

Currently 0.5MB is dedicated to a lot of languages I will never make use of. Is there a way to build the MDEditor such that I can only import the ones I need hence reducing the bundle size?

image

@jaywcjlove
Copy link
Member

@martinomburajr

### Remove Code Highlight
The following example can help you _exclude code highlighting code_<!--rehype:style=color: #333;background-color: rgb(196 255 122 / 86%);--> from being included in the bundle. `@uiw/react-md-editor/nohighlight`<!--rehype:style=color: #e24444;--> component does not contain the ~~`rehype-prism-plus`~~ code highlighting package, ~~`highlightEnable`~~, ~~`showLineNumbers`~~ and ~~`highlight line`~~ functions will no longer work. ([#586](https://github.com/uiwjs/react-md-editor/issues/586))
```jsx mdx:preview
import React from "react";
import MDEditor from '@uiw/react-md-editor/nohighlight';
const code = `**Hello world!!!**
\`\`\`js
function demo() {}
\`\`\`
`
export default function App() {
const [value, setValue] = React.useState(code);
return (
<div className="container">
<MDEditor
value={value}
onChange={setValue}
/>
<MDEditor.Markdown source={value} style={{ whiteSpace: 'pre-wrap' }} />
</div>
);
}
```

@martinomburajr
Copy link
Author

Thanks, no way to specify specific code highlighting? e.g. Go, and SQL only, or any other combination

@jaywcjlove
Copy link
Member

@martinomburajr You need to add this yourself.

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

2 participants