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

Syntax highlighting Code component in docs explanation #811

Open
1 of 2 tasks
diploidal opened this issue Dec 30, 2022 · 1 comment
Open
1 of 2 tasks

Syntax highlighting Code component in docs explanation #811

diploidal opened this issue Dec 30, 2022 · 1 comment

Comments

@diploidal
Copy link

About docs

This is a document site related issue.

Languages

  • English
  • Chinese

Description

I've noticed that Code component in docs uses:

<Code block my={0}>
  <ExampleCodes />
</Code>

I'm having a problem with implementing that component with my custom code examples in it.

<Code block my={0}>
  const a = 'something';
</Code>

or something like this:

const CodeSnippet = () => `
  <div>
    <span>Hello Code snippet!</span>
  </div>
`;

and then

<Code block my={0}>
  <CodeSnippet />
</Code>

but in this particular example CodeSnippet returns string and Code does not add any syntax highlighting.

It would be great to add an explanation how our code snippets should be prepared in order Code component to highlight their syntax properly and/or detect different languages.

Or maybe just add <ExampleCodes /> as a reference. 🤔

Am I the only one who does not get how to use Code component properly ? 😅

Page Links (Optional)

https://geist-ui.dev/en-us/components/code#code-block

@Nedgeva
Copy link

Nedgeva commented Feb 8, 2023

AFAIK Syntax highlighting is not something that coming out of box. I used react-syntax-highlighter package as foundation for syntx highlighting.

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